Git Product home page Git Product logo

commandbot's Introduction

workspace arch-linux firefox discord
editors nvim
tools github-actions docker git
languages python rust bash
pgp itsdrike-key

Hey there ๐Ÿ‘‹

  • ๐Ÿ˜ I usually work on back-end related development and algorithm design.
  • ๐Ÿ‘จ I'm addicted to automating everything and a huge advocate of CI workflows, unit testing, and other DevOps related technologies.
  • ๐ŸŒฑ Currently, I'm learning about system administration and security.
  • โš™๏ธ I like exploring low-level languages, such as Assembly, Rust and C.
  • ๐Ÿ’ฌ Ask me about anything, I am happy to help.
  • ๐Ÿ“บ I enjoy watching TV shows, mostly Sci-Fi/Fantasy.
  • ๐Ÿ“ซ Reach out at [email protected] or through Discord, by sending a friend request to @itsdrike
๐Ÿ“Œ Detailed metrics
๐Ÿ™‹ Profile Details ๐Ÿงฎ Repositories traffic
๐Ÿ“… Isometric commit calendar ๐Ÿˆท๏ธ Most used languages
โ™ Code snippet of the day ๐ŸŒŸ Recently starred repositories
๐Ÿ’ก Coding habits โฐ WakaTime plugin
๐Ÿ“ˆ Extensive wakatime details

Code Time

I'm a Night ๐Ÿฆ‰

๐ŸŒž Morning                1251 commits        โ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   08.68 % 
๐ŸŒ† Daytime                4407 commits        โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   30.57 % 
๐ŸŒƒ Evening                5369 commits        โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   37.24 % 
๐ŸŒ™ Night                  3390 commits        โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   23.51 % 

๐Ÿ“… I'm Most Productive on Monday

Monday                   2513 commits        โ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   17.43 % 
Tuesday                  2025 commits        โ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   14.05 % 
Wednesday                2099 commits        โ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   14.56 % 
Thursday                 1997 commits        โ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   13.85 % 
Friday                   1816 commits        โ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   12.60 % 
Saturday                 1728 commits        โ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   11.99 % 
Sunday                   2239 commits        โ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   15.53 % 

๐Ÿ“Š This Week I Spent My Time On

๐Ÿ’ฌ Programming Languages: 
Python                   9 hrs 17 mins       โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   41.00 % 
Nix                      5 hrs 1 min         โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   22.21 % 
TOML                     3 hrs 9 mins        โ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   13.97 % 
Lua                      2 hrs 15 mins       โ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   09.95 % 
JSON                     1 hr 17 mins        โ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   05.69 % 

๐Ÿ”ฅ Editors: 
Neovim                   22 hrs 39 mins      โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ   100.00 % 

๐Ÿ’ป Operating System: 
Linux                    22 hrs 39 mins      โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ   100.00 % 

I Mostly Code in Python

Python                   43 repos            โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   56.58 % 
C++                      8 repos             โ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   10.53 % 
C#                       2 repos             โ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   02.63 % 
Nix                      2 repos             โ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   02.63 % 
Java                     1 repo              โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   01.32 % 

Last Updated on 14/07/2024 01:44:45 UTC

commandbot's People

Contributors

dependabot[bot] avatar itsdrike avatar janasunrise avatar

Watchers

 avatar

commandbot's Issues

Add an option to mute channels

The staff members should be able to mute whole channels while resolving some issue, this can be helpful to prevent spam from other users and to force others to read their messages before they get lost in the chat.

Staff should only be able to do this in certain channels (possibly the ones they have manage messages permission for) to prevent this from happening on protected channels.

Staff Members should still have a right to talk in that channel.

The command for this can be something like this: !mutechannel [time] where time will specify the duration for which the channel will be muted (it is probably a good idea to also put a restriction on maximum mute time in case this should ever be abused)

There can be an override to this maximum mute duration, but only MODERATION ROLES should have access to this.

The implementation shouldn't be too hard as it is possible to change the permissions for @everyone in specified channel to disallow sending messages, which can then be undone (a timer can be set up using the asyncio library).

Add Unit Tests

Unit Testing should be a part of every project, that includes this one.
It will make it a lot easier to find mistakes and fix them.

Unit Testing must include a custom module that will include most of the custom discord.py classes so that they can simply be used by importing them, as most of the functions which will have to be tested will require these values. A sensible way to do this would be to use unittest.mock

Add Pipfile scripts to improve usability

There should be a more sensible way to start the bot than either being in the venv and using the start.py script to start the bot.

Instead we should focus on using Pipfile scripts which will allow to "alias" an action, providing a better way to start the bot.

This is not limited to starting the bot, other features can be implemented with this too, f.e.:

  • Linting (Run pre-commit linting check on all of the files)
  • Precommit (Install pre-commit)

Merge Scheduler to Silece directly

PR #36 has added a way to silence channels. It is using the UnsilenceScheduler class which inherits from Scheduler to unsilence the channels after the set delay expires.

While this approach works fine, there is no need for this external UnsilenceScheduler class, we can simply include Scheduler class as a parent of Silence cog directly and implement the scheduling from there.

This would be a better solution since the code will be cleaner and there will not be a need to pass in an instance of Silence class (cog) to UnsilenceScheduler every time a channel is silenced

Refactor "Help" Command

Discord.py redesigned and created how help commands work - some helpful links:

A refactor to subclass the HelpCommand class and friends shouldn't have any outward-facing changes, but it will clean-up and update the code to be compatible with any future releases, as well as ctx.send_help

Create reminders cog

A new cog" reminders should be added which will contain the commands for reminding users of anything. The command syntax should look like this:

!remindme [duration] [remind note], where duration will specify when the reminder will go off and the remind note is what you will be reminded of.

There can also be a possibility to set whether you want to be reminded in the server by mention or using DM.

This will require a database since if the bot will get restarted, all of the timers will reset, this means every reminder should be saved into the database table from which they will be removed when executed (sent) - similarly to infractions.
There should also be a check whether the user which wanted to be reminded is still on the server, in case he isn't, remove it (there is no point in reminding someone who isn't there to see it).

Proposed reminders can look something like this:
image
when in DM, or with included user mention when on server

Add voting command

There should be a command which will add voting. This should bring its own "vote-building mode" similarly to embed building mode in which you can create the poll and set-up the options. You should then be able to send this pool to any channel (which you have access to) and the poll will become functional using the emojis for reaction.

There should be at least 2 formats of polls:

  • !yesnopoll (A simple yes/no question) Voting can be done with these reactions:
    image

  • !optionspoll (A more complex question with multiple possible answers) Voting can be done with these reactions:
    image

Infraction message too long

It doesn't happen often, but there are cases when the infraction list message is too long so there should be a system in place that could divide the infraction content to smaller pieces possibly using pagination

Add leveling system

A leveling system can be added to gamify the bot a bit. This should be implemented with/after #2 and it should count every message the user sends (possibly even the length of those messages) and set-up levels based on that amount.

  • This also gives us the possibility to assign custom privileges to users with higher levels.
  • Moderators should have access to commands which could adjust user levels manually.
  • There can also be a top dashboard that will show the users with the highest levels on the server.
    Any user should be able to display his own status which will include his current level, his "XP/MaxLevelXP" (Which will indicate how far he is from level-upping) and his rank on the server
  • It can be useful if this system had an option to ignore these levels for Staff Members, although that should be a toggleable feature.

Add a slowmode command

There should be a possibility to make channels use slow-mode simply by using a command.

This should use the Duration converter for the time limit. This can be quite handy to avoid spam.
The slow mode should be applied only when the user has permission to manage that channel and is a member of STAFF ROLES.

There should also be a timer for specifying how long will this slow mode last.

Custom config to override the default

Rename config.yaml to default_config.yaml.
Use config.yaml as higher-priority config, so values in this config will be preferred, but if there is no value for something, it will fall back to default_config.yaml

This will be useful when changes are made to config.yaml (now default_config.yaml) there won't be issues with overriding the changes to config made by the user.

Rework the `in_channel` decorator

The in_channel decorator should have more options:

  • Rename in_channel to a more meaningful in_whitelist
  • Rename InChannelCheckFailure to InWhitelistCheckFailure
  • Pass channels as a keyword argument
  • Add option to whitelist categories
  • Add option to add redirect channel which will be used when printing error message (default value of this should be the #commands channel)
  • In case no redirect channel is provided (explicitly set to None) there shouldn't be any channel mentioned in the error message
  • If the decorator is called from DM, raise InWhitelistCheckFailure with Commands issued in DM channel should be rejected as error message
    This will provide more flexibility for future usage as it will not necessarily give the channel name where the command should be used, or the channel can be specified instead of printing a list of all possibilities.

Add Fun Cog

Add new Cog for Fun commands

Possibilities:

  • Dice roll (!dice 2d4 would be 2x roll of 4-sided dice)
  • Riddles (Let user guess. If there is no correct guess after some interval, reveal answer)
  • Minigames (eg. Tic-Tac-Toe, Minesweeper)
  • Really anything

Infractions don't work without description

After #23 was merged if the description is not passed to new infractions it will result in an error, since self.result in infraction will explicitly be set to None which is then ignored by the automatic SQLite sanitization of strings. Therefore every time there is an infraction without reason, it should be explicitly set to "None" string instead of being None directly.

Add a full README.md file

Currently, the README only says work in progress, which is true, but the bot is currently production-ready so it can contain some more details:

  • How to install the requirements and get the bot running
  • Setting up the config.yaml file
  • Using the bot

Setup Travis-CI

We should setup Travis-CI utility to run all the unit tests automatically.
This will save us a lot of time when debugging.

Message Count

Feature request for message scoreboard and total message count of any given user.

Cog should be named usermessages and it should contain:

  • Message scoreboard which would keep track of users with most messages
  • Individual user message count
  • Show top user and his message count

Allow clear command only for Manage Messages

It doesn't make sense to allow !clear command in channels where staff members shouldn't be allowed to (when they don't have Manage Messages permission)

There should be a check which only allows using !clear if you have sufficient permissions in that channel

Add filtering cog

A filtering cog should be added to prevent users from posting unwanted messages

This cog should remove:

  • Blacklisted words in config
  • Blacklisted domains
  • Discord invite links
  • Zalgo text

Staff roles should be exempted from this filtering, although if their message matches some of these patterns, it should be logged in modlog

Sanitize infraction message

The infraction message should never contain quotes due to the way it is displayed:

The way it's supposed to be displayed:
image

The issue happens when the infraction message contains " or ' as this will result in bad color formatting in this codeblock.

image

Therefore we should either edit all of the quotes to be prepended with \ therefore ignoring that issue, although this might be confusing since the reason will be different from what was intended, or we should sanitize the message so the infraction message can't contain such characters.

Use selector event loop on windows

With the 3.8 python update, the default event loop on windows is now the ProactorEventLoop; one of aiohttp's dependencies uses features which are not supported in this event loop leading to crashes on startup on windows with an undescriptive error

From cffi callback <function _sock_state_cb at 0x0000000003816040>:
Traceback (most recent call last):
  File "C:\Users\test\.virtualenvs\bot-K_QdelnW\lib\site-packages\pycares\__init__.py", line 91, in _sock_state_cb
    sock_state_cb(socket_fd, readable, writable)
  File "C:\Users\test\.virtualenvs\bot-K_QdelnW\lib\site-packages\aiodns\__init__.py", line 105, in _sock_state_cb
    self.loop.add_reader(fd, self._handle_event, fd, READ)
  File "C:\Users\test\AppData\Local\Programs\Python\Python38\Lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

This can be fixed by setting the event loop policy to WindowsSelectorEventLoopPolicy through asyncio.set_event_loop_policy when the platform is detected to be windows

Add ability to unload/load a cog

Create a new cog which will be used to unload/load cogs using commands.
There should also be a reload command implemented in case some cog fails.
A list command would also be a good idea in order to see which cogs are currently loaded and which aren't.

Note that this cog shouldn't be able to unload itself and neither the modlog cog to prevent abuse

Show rules

Add rule/rules commands to the Informations Cog, which would handle showing rules to players

  • !rule 1, which would show the first server's rule
  • !rules which would point the user to the #rules channel

Use UTC time instead of local time

We should be using UTC instead of the local timezone for all time-related operations, as it doesn't make sense to use local timezone for global server purposes.

Option to use embed messages for staff

It would be handy if certain staff members (Maybe even some higher-ranked users) could have the option to use the !embed command which would produce an embed of their messages (their message should then be removed to prevent spam). This action should also be logged in the message-log channel.

Help not getting invoked

After #12 was merged, error_handler cog has not been updated to respect this new help system

async def handle_user_input_error(self, ctx: Context, e: errors.UserInputError) -> None:
"""
Send an error message in `ctx` for UserInputError, sometimes invoking the help command too.
* MissingRequiredArgument: send an error message with arg name and the help command
* TooManyArguments: send an error message and the help command
* BadArgument: send an error message and the help command
* BadUnionArgument: send an error message including the error produced by the last converter
* ArgumentParsingError: send an error message
* Other: send an error message and the help command
"""
help_command = await self.get_help_command(ctx.command)
if isinstance(e, errors.MissingRequiredArgument):
await ctx.send(f"Missing required argument `{e.param.name}`.")
await ctx.invoke(*help_command)
elif isinstance(e, errors.TooManyArguments):
await ctx.send("Too many arguments provided.")
await ctx.invoke(*help_command)
elif isinstance(e, (errors.BadArgument, errors.BadUnionArgument)):
await ctx.send(f"Bad argument: {e}\n")
await ctx.invoke(*help_command)
# elif isinstance(e, errors.BadUnionArgument):
# await ctx.send(f"Bad argument: {e}\n```{e.errors[-1]}```")
elif isinstance(e, errors.ArgumentParsingError):
await ctx.send(f"Argument parsing error: {e}")
else:
await ctx.send("Something about your input seems off. Check the arguments:")
await ctx.invoke(*help_command)

This should be rewritten together with self.get_help_command function to respect the new help system.

image

Use screen when running on Linux

It would be better to start a new screen as a daemon when starting the commandbot.service instead of having the output only stored in the log file and directly as stdout from the service.

Note that this only applies on linux.

Changes to embeds cog

The new embeds cog is good, but it could use some further edits:

  • An option to add text to description instead of only setting it. (This also applies to fields)
  • An option to set the text of a non-embed message (can be helpful for mentions), this message should be posted before the embed itself
  • Fix footer mentioning: Mentioning user/channel in footer produces a <#[channel id]>/<@![user_id]> instead of normal mention, while it is impossible to directly mention a channel in the footer, it should use plaintext for mentions @mention or #channel even though it will not produce a clickable mention, it is much more readable compared to the current formatting.

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.