Code Monkey home page Code Monkey logo

monkeybot's Introduction

Build Status Contributors Issues MIT License Discord


2023-03-23: The code hasn't been updated in quite a while and will probably break in the foreseeable future when the Discord API keeps changing. I don't have the time nor energy to keep working on this as it is rarely ever used. Feel free to fork it or take inspiration from it.

Logo

MonkeyBot

A general purpose Discord Bot for the Monkey Gamers community written in C#
Explore the available commands »

Join Chat · Report Bug · Request Feature

Table of Contents

About MonkeyBot

MonkeyBot is a general purpose Discord Bot that was created for the needs of the Monkey Gamers community. Its main functions are:

  • Welcoming new users
  • Get updates from various feeds (ATOM/RSS)
  • (Self) role assignments
  • Scheduled announcements
  • Game server tracking
  • Stream announcements
  • Handling of applicants (planned)
  • Silly stuff like Picture search, Trivia, Chuck Norris jokes, Benzen Facts, xkcd...

Built With

Getting Started

Prerequisites

  • Latest .NET SDK for your platform (7.0 or later) - you can download it here
  • A registered Discord application with a bot access token. If you don't have one, you can create one with your existing Discord account here. There you have to add a Bot and need to copy both Bot Token and Client ID. To then add the bot to your Discord server go to https://discordapp.com/oauth2/authorize?scope=bot&permissions=0&client_id=[ID], replacing [ID] with the Client ID of your bot (not the token)
  • Optional: An IDE of your choice (Visual Studio 2022 recommended)

Installation

  1. Clone the repo

    git clone https://github.com/MarkusKgit/MonkeyBot.git   

    or download it from GitHub and unzip it

  2. Pick the right branch The latest stable version is on the main branch: git checkout main If you want to try the latest development build then check out the development branch: git checkout develop

  3. Build

    cd MonkeyBot
    dotnet build

    or open the solution in Visual Studio and build

  4. Run

    dotnet run

    On the first run of the Bot the configuration file will automatically be created by prompts on the command line. For a first test you only need to provide the Bot access token. The configuration will be stored in /config/configuration.json. Look at exampleconfig.json to see the structure of the config file if you wish to create it manually.

  5. Publish

    To permanently run the bot you should publish it first:

    dotnet publish -c Release --output published

    Then you can create a daemon/service that automatically runs dotnet published/MonkeyBot.dll Here is an example for a system.d config file (tested on Ubuntu server):

     # /etc/systemd/system/MonkeyBot.service
     # To enable: sudo systemctl enable MonkeyBot.service
     # To start: sudo systemctl start MonkeyBot.service
     
     [Unit]
     Description=MonkeyBot service
    
     [Service]
     WorkingDirectory=/home/markus/MonkeyBot/published
     ExecStart=/usr/bin/dotnet /home/markus/MonkeyBot/published/MonkeyBot.dll
     Restart=on-failure
     RestartSec=10
     SyslogIdentifier=monkeybot-service
    
     [Install]
     WantedBy=multi-user.target

    Updates to new versions are then as easy as:

    sudo systemctl stop MonkeyBot.service
    cd /home/markus/MonkeyBot
    git pull
    dotnet publish -c Release --output published
    sudo systemctl start MonkeyBot.service

Usage

Once the bot is running and connected it will respond to commands. Try !help to get you started.

Troubleshooting

Logfiles are stored in Logs directory and fatal errors will also appear in the command line output. The SQLite database is located in the Data directory. If you have any questions or found a bug you can open an issue or get in touch on Discord

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. Have a look at our Contributing guidelines for more info.

tl;dr:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request against the develop branch

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Project Link: https://github.com/MarkusKgit/MonkeyBot

Discord: https://discord.gg/Ypdx2y7T2n

Acknowledgements

Features:

For a full list of commands see Commands

monkeybot's People

Contributors

ashwin003 avatar brammys avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar laxynium avatar markuskgit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

monkeybot's Issues

Migrate to DSharp+

DSharp+ seems to be more actively maintained and it also offers some interesting functionality like first class Interactivity

Fix NLog Initialization

In the latest version of NLog the initialization with loggerFactory.AddNLog is obsolete.
We need to figure out what is the prefered new way of setting up NLog with DI.
The fix needs to be done in Initializer.cs

Fix gameservers feature

At the moment the feature to track gameservers isn't working after all the recent upgrades. In fact the commands to add/remove game servers somehow got deleted on the way.

Restore the functionality and test with multiple different servers

Improve trivia

Trivia has been untouched and untested for too long.

First it needs to be upgraded to using buttons instead of reactions. Second it need thourough testing to make sure it still works.

Apply Command

For our community we need to handle applicants in a smarter way. A couple of commands that handle applications should be created:

The main one is obviously !apply after which the applicant should answer a series of questions that can be configured by the guild admins in seperate commands (something like !addquestion and !removequestion). The applicant should also receive a temporary applicant role. Guild admins can then use !accept *user* or !deny *user*.
It could also be considered to make a thread in an applicant channel per application.

Example workflow:

  1. Admins set up questions, application channel and applicant role and member role
  2. Applicant uses the apply command. After they answer the questions they get the applicant role and possibly a thread in an applicant channel is created for them, where the answer to the questions is presented
  3. Application can be discussed by the community members and then either denied or accepted. If accepted the user gets the member role. In any case the applicant role is removed

The applications and application configurations should be stored in two new Database tables.

Update the readme with some usage examples

The readme should probably highlight some functions of the Bot that stand out, for example the feed and game server updates. It should include a short description and a screenshot

Testing

Currently the code is completely uncovered by tests. Figure out what parts of the code can be tested easily and which require more work.
For a start the services that don't depend on Discord should be tested. Try to find good examples how to test the stuff that is more tightly coupled to Discord like command handling.

Bot greeting

Add a nicely formatted message for any new guild the Bot joins. It should contain some instructions for first use, a link to the Documentation and the help Discord Guild

Simplify announcements/reminders

The announcements reminders module is another candidate that new some overhauling.
Consider renaming it to Reminder (done), get rid of the command group (make the commands individual, e.g. !setreminder) and possibly make it easier to use with the help of interactivity. Also use the new time formatting option of Discord

Enhance Polls

Enhance the poll feature by using actual buttons instead of reactions

Fix HttpClient usage

Currently we are creating new HttpClient instances for various API requests in different services.
As per https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/ this is not the right way There are two options:

  1. one global static instance of HttpClient
  2. Use HttpClientFactory that was introduced in Net Core 2.1 see

I prefer the 2nd option

Better self role management

Consolidate the existing self role management methods by using the new Buttons/Drop Down feature

!addrole should present a drop down of roles you can assign to yourself. Upon clicking one item the user should get that role. On the other hand !removerole should present a dropdown list of roles the user already has. Upon click the role should get removed from the user.

Similarly an admin can add a role dropdown to any message, e.g. on the welcome page (like the current role "buttons"). So users can pick roles at any time without having to use the !addrole command first.

Check command permissions

At the moment the permissions for the commands (both by the Bot and the user) are not consistent.

Go over every command and apply the correct needed permissions for both the Bot and the User.

Fix CI

From AppVeyor log:
C:\projects\monkeybot\MonkeyBot\MonkeyBot.csproj.metaproj : warning MSB4078: The project file "MonkeyBot\MonkeyBot.csproj" is not supported by MSBuild and cannot be built
So AppVeyor never actually verifies the build is okay

Find out why it is not working and consider switching CI provider

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.