Git Product home page Git Product logo

clembotproject / clembot Goto Github PK

View Code? Open in Web Editor NEW
83.0 4.0 57.0 26.69 MB

A Discord bot for server management with an emphasis on modularity and configuration. If you have an idea or a feature you would like to contribute feel free to open an issue and we as a community can begin discussion.

Home Page: https://clembot.io

License: MIT License

Python 51.24% Dockerfile 0.14% C# 42.82% JavaScript 0.65% SCSS 0.50% Vue 3.98% TypeScript 0.64% CSS 0.03%
python discord-py discord-bot moderation dotnet csharp

clembot's Introduction

ClemBot Logo

ClemBot


Support Made with Python 3.10 MIT License

ClemBot

Website, Documentation and Configuration Dashboard

https://clembot.io

Intro

A Discord bot for server and community management with a focus on school/programming/fun related commands.

  • Moderation: Moderation and Moderation logging is made easy with ClemBot, Banning, Muting and Warning are all supported and easy to use

  • Role Management: Easily manage you and your users roles with designated assignable roles

  • Customizable Prefix: Whatever you want ClemBot to respond to, it can. Just set your servers preferred prefix with !prefix <prefix>.

  • Python Repl: Coding is fun, Discord is fun. Put them together and collaborative learning is easy with a built-in python interpreter. Just type your python code into discord and run it with !eval and watch the bot evaluate your code.

  • Message Logging: ClemBot offers the ability to log message edits and deletions, just run !channels add message_log #mychannel to designate a channel as a log message

  • Tags: Tags allow you to create message snippets that can be invoked right in discord with a simple inline command. Just run !tag add <MyTagName> <MyTagsBody> and invoke it with $MyTagName

  • Welcome Messages: You can optionally set a message to be sent to new members of your server. Making it easy to make sure people understand rules and procedures.

  • Expression Evaluator: ClemBot implements the shunting yard algorithm to allow for rapid mathematical expression evaluation right in discord. just run !calc 1+1 to get your result

  • ...and so much more!

ClemBot is in current active development so check back often to see what's new!!

Bot Invite

To invite ClemBot to your server, click here.

Community

We are a community focused on learning and acceptance; anyone is welcome. If you have an idea or a feature you would like to contribute, feel free to open an issue and we as a community can begin discussion.

Development

To start developing and contributing to this project, please see CONTRIBUTING.md

Architecture overview

ClemBot utilizes a standard three tier architecture. The ClemBot.Bot project makes requests to the ClemBot.Api project, which then subsequently queries the PostgreSQL database.

ClemBot.Bot

The bot is set up in a simple way. There are 3 layers, the Cog Layer, the Service Layer and the Route Layer. Cogs and Services communicate exclusively through the messenger. This allows us to maintain total decoupling of the layers.

  1. Cog Layer: This is where the frontend bot command code resides. Anything that you directly use to interface with discord goes in this layer.
  2. Service Layer: This is where all things that are bot related but not controlled through front end commands live. Things like user tracking, event handling, etc., all go in here.
  3. Route Layer: This is the route abstraction on top of the ApiClient. This layer defines methods that correspond to routes that are sent back to the ClemBot.Api project

The bot loads Cogs and Services dynamically. To create a new command, simply create a class that inherits from commands.Cog and define a setup function in module scope at the bottom. See example_cog.py for an example.

The bot does the same thing for services, to see how to define a service, see example_service.py.

ClemBot.Api

The API utilizes the following technologies...

...and is split up into several different projects under one solution:

  • ClemBot.Api.Data contains the Entity Framework code-first database models and contexts.
  • ClemBot.Api.Core contains the startup project and Asp.Net endpoints located in the Features folder.
  • ClemBot.Api.Services contains the caching and authorization services that perform more complex tasks.

ClemBot.Site

The site is a server-side Nuxt.js and Vue.js app that integrates with Discord OAuth.

ClemBot Pipeline Status

Service Pipeline Status
Api ClemBot.Api Master Integration ClemBot.Api Master Integration
Api ClemBot.Api Master Deployment ClemBot.Api Master Deployment
Bot ClemBot.Bot Master Integration ClemBot.Bot Master Integration
Bot ClemBot.Bot Master Deployment ClemBot.Bot Master Deployment
Site ClemBot.Site Master Integration ClemBot.Site Master Integration
Site ClemBot.Site Master Deployment ClemBot.Site Master Deployment

clembot's People

Contributors

adanielpincab avatar arock475 avatar brenapp avatar butteredwaffles avatar clemsonjames avatar codysgithub avatar dependabot[bot] avatar ellieswaim avatar emimendoza avatar exper1mental avatar iapetus-11 avatar jay-madden avatar jhollowe avatar jkriste avatar kellenjames avatar lucario avatar makayla-moster avatar matthewperrydev avatar new-zelind avatar patrickklaeren avatar paynejordand avatar pmerry96 avatar r3cebarnett avatar rajatsethi2001 avatar sctigercat1 avatar sea-shore-sahil avatar smathep avatar steve4git avatar tyler-macinnis avatar zepthro avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

clembot's Issues

Add Commands Abbreviations

Got the idea while figuring out how to squash commits in Git Bash.

The following do the same thing:

git rebase -i 60042c8
git rebase --interactive 60042c8

My idea is to apply this same concept to commands we use with the bot. The (obvious) benefit is being able to reduce the typing required for commands while preserving the longer, more descriptive command names as well.

Example:

$ role add Junior

Could also be called using

$ -r -a Junior

or something like that.

Ideally we'd want to agree on a naming system for the abbreviations

Would tie in well with updating the help command (#127)

Blackjack / Texas Hold'em / 5 Card Stud games

Something cool would be if the bot had a way to play poker with other people. Start each player off with like, 100 coins, and they could place their bets through a DM message and win/lose coins by playing poker.

$poker [<@User1>, <@User2>, ...<@UserN>]

A calculator feature

I noticed that several channels on the Discord could use a simple calculator as those classes are heavier in math. What specific features and functionality would you like to see?

Cog to manage classes

this is core bot functionality, we need a way to manage classes and roles without having to do it manually, there is a decent amount that will go into this database and service wise so this will be a rolling pr

Exception handling

Currently some exceptions are swallowed at the top level, we need a way to bubble them up to discord to be logged

Database layer throws primary key errors

Currently the db layer doesnt check before it attempts to insert a record, this needs to be changed and a pre check inserted. Exception control flow is never good

Make "Command Not Found Errors" Return Command List

Pretty self explanitory. If the user sends a command that doesn't exist, e.g. $dice_role, the bot sends with the error message a list of roles that do exist. Ties in with the changes for #127.

Additional Idea:

If the user sends an agrument that doesn't exist, such as $role new, the bot could provide a list of acceptable arguments.

Problem:
Help message for arguments could be problematic. For some commands the user can provide input, such as $role requested_role. I think an additional argument would need to be added so the bot knows to not treat the user input as an incorrect argument. (e.g. $role request requested_role)

TLDR command

There was some talk about a TLDR command/channel being made.
Some ideas that were brought up.

  • Taking a link from the message at the beginning of a conversation. Adding a TLDR for the conversation. Either adding the TLDR and link to a TLDR channel or making it searchable, maybe by title.
  • Finding some way to link messages together and adding them to a TLDR. This could take upvotes for what is important to the conversation in to account.
  • Calling tldr with no arguments returns the most recently created TLDR

Revamp Help command

The default d.py help command is ugly and a way to make it pretty would be very nice

More log statements, ONGOING:

Currently not all actions the bot takes are logged, this issue will serve a center point for log statement related commits to go. This is a great way to get your feet wet with contributing to the bot and with githubs workflow.

PyPubSub is a synchronous library

PyPubSub is synchronous and not async which makes it impossible to use in this context. Upon research it appears that a light weight asynchronous event aggregator. the only thing i have found is this https://pyzmq.readthedocs.io/en/latest/api/zmq.asyncio.html.

TODO: to move forward we will need to either roll our own event framework or use zmq. if anyone has any further suggestions or comments please leave them down below. We also need to strip out the pypubsub dependency and generate a new freeze file

Revamp how services are loaded

We need a way to idiomatically define how services handle their startup and shutdown procedures, i propose an abstract base class that defines a load method that handles such things

CUConnect Feature

match students in Clemson School of Computing that have similar hobbies and classes using a nearest neighbors search

Add a teacher feature to the !grades command

the grades command has been very popular and helpful. However, it is often wanted to compare individual teachers to make an informed decision on who to take. I propose if possible we add a way to get professor specific info

Source Command Drops Last Line of Code

Small bug I noticed when asking the source command to print specific lines of code. The last line seems to get dropped.

Example <bot_prefix>source example_cog.py 1 3 would only print lines 1 and 2:

1:    #what the bot does 
2:    import logging

Multiple tags in a message

Since Jay is a coward, only the first tag in a message will work correctly:

this first $tag1 will work but this second $tag2 will not

Obviously, this needs to be fixed.

Logging revamp

Currently the logs overwrite themselves on restart. This is bad practice as history is lost. I suggest we move to a date specified format where each restart takes the current time and appends it to the file name, making it unique to that run

Invalid filenames using datetime.datetime.utcnow() on Windows

The !crab command saves the .gif file with a filename that contains invalid characters when the bot is running on Windows.
The datetime.datetime.utcnow() needs to be formatted with strftime()to remove colons (and maybe spaces?) instead of being used directly in a format string.

Make Role Assignment Non-Case Sensitive

Should be pretty self explanitory.

Normal Example
Roles:

  1. Freshman
  2. Sophomore
    ...

User: !role sophomore

Bot: Role assigned: Sophomore

Special Case Example
Roles:

  1. JUNIOR
  2. junior

Ignoring case, there are two possible roles the user is requesting. In this situation, my thought is to perform a case-sentitive evaluation of the user input corresponding to the roles. If not role exists, return an error listing the possible roles the users might've been requesting. Since there are two possible roles the user is requesting, the bot will need to

Special case example 1:
User: !role Junior
Bot: Error, role not found. Two possible roles: 1. JUNIOR or 2. junior

Emojis could be used to have the user select which role they wanted.

Special case example 2:
User: !role junior
Bot: Role assigned: junior

For this special case, I'm wondering if there should be a warning even if the user types in the case-senseitive role to inform them of another possible role they might otherwise be unaware of.

Command authentication

An authentication module is badly needed as the default d.py auth code is very very limited

Add command to role cog to add role based on channel

when in a channel with an associated role (from the class cog), the command (i.e. !role apply) would add the role for that class to the user who called the command.

For example: When I am in the cpsc-1010-teacher channel and run the command !role apply, I would receive the cpsc-1010 role

PsuedoThreading

Hello,
In the channel that uses this bot, we had considered the Slack feature of threading comments.

To do so, you must leverage the properties of a thread of messages - Also called a tree.

For example (messages are numbered for use later, These numbers will be used in place of links),
1 Student 1: I have this question.
2 TA: This is the response to your question
3 Student 1: Please clarify this point
4 TA: Here is clarification
5 Student 1: $Thread_close

When the $thread_close command is issued, the bot will be able to do the following
Take the link to last message in the thread
put the link on a stack
navigate to the link on top of the stack
If the new current message has a link, put it on a stack and recurse. Otherwise, pop the top off the stack and append the message to the transcript.

Using the example conversation above, the bot will construct the stack until it reaches a message with no link.
The stack will look like this (top) {1,2,3,4} (bottom)
the bot will then pop the top, follow link, and append the contents to the transcript until the stack is empty.

Thus the transcript becomes (contents omitted, messages referred to by number from original conversation)
1
2
3
4

This allows for each individual offshoot of a thread to be closed independently. In the context of a tree, this means a leaf node can either spawn a child (a reply to a message in a thread) or decide to stay a leaf (close the thread). Because the action of any leaf is independent of any other leaf, every thread can be closed and have its path from root->the aforementioned leaf node.

For another example - Consider Students 1,2,3 and the TA named "TA". They may have a conversation like so
1: I have a question
2: <Link to 1's question> That reminds me of my question
3: <Link to 1's question> This reminds me of a different question.
TA: <link to 1's last message> Answer to your question
TA: <link to 2's last message> Answer to that question
TA: <Link to 3's last message> Answer to another question
1: $Thread_close <link to the TA's answer to their question>
2: $Thread_Close <link to TA's answer to their question>
3: <Link to TA's answer to their question> Please clarify on your point.
TA: <Link to 3's last message> Here is clarification
3: $Thread_close <link to TA's answer to their request for clarification>.

Thus a tree is created. In the tree, the links were replaced with edges from parent to child. To see the tree, please view the image here: https://i.imgur.com/zw1Opop.jpg

This is each individual transcript that individual users would see
1 -
1: I have a question
TA: <link to 1's last message> Answer to your question
1: $Thread_close <link to the TA's answer to their question>

2 -
1: I have a question
2: <Link to 1's question> That reminds me of my question
TA: <link to 2's last message> Answer to that question
2: $Thread_Close <link to TA's answer to their question>

3 -
1: I have a question
3: <Link to 1's question> This reminds me of a different question.
TA: <Link to 3's last message> Answer to another question
3: <Link to TA's answer to their question> Please clarify on your point.
TA: <Link to 3's last message> Here is clarification
3: $Thread_close <link to TA's answer to their request for clarification>.

I believe I have belabored my point by now. If you have any questions please place them in the comments.

A random gif getter

I envision a command that you can call that will send back a random gif, will probably need to be filtered for nsfw results

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.