Cogs for the Red-DiscordBot-based Homelab Discord server bot.
- LabBot Cogs
- Table of Contents
- Contributors
- Cog Summaries
- Cog Documentation
- License
- Contributing
This is a joint project involving any of the Homelab Discord admins, moderators, and community members that would like to get involved.
A number of people have contributed to this project, both current and former members of the moderation team and members of the wider community.
A massive thank you to all who've helped with this project ❤️
- AutoReact: React to specific phrases with one or more emotes.
- AutoReply: Automatically replies to messages that match a trigger phrase.
- BetterPing: Outputs the current channel topic as a message in the channel.
- Convert: Converts any unit to any another unit.
- Custom-msg: Allows moderators to send/edit messages from the bot.
- Enforcer: Allows you to enforce certain characteristics on a channel.
- Feed: This allows users to feed each other.
- Google: Send a google link to someone.
- IsItReadOnlyFriday: Answers if it's read-only Friday (or December).
- LaTeX: Render a LaTeX statement.
- Letters: Outputs large emote letters/numbers from input text.
- Notes: Manage notes and warnings against users.
- Penis: Allows users to check the size of their penis.
- prometheus_exporter: Exposes a HTTP endpoint for exporting guild metrics in Prometheus format.
- Purge: This will purge users based on criteria.
- Quotes: Allows users to quote other users' messages in a quotes channel.
- Reactrole: Allows roles to be applied and removed using reactions.
- Report: Allows users to report issues.
- Roleinfo: Displays info on a role
- Sentry: Send unhandled errors to sentry.
- Tags: Allow user-generated stored messages.
- Timeout: Manage users' timeout status.
- Topic: Outputs the current channel topic as a message in the channel.
- Verify: Allows users to verify themselves.
- xkcd: Allows users to look at xkcd comics.
This cog allows mods to add auto reactions to certain phrases.
[p]autoreact
This cog automatically responds to messages that match specific trigger phrases, set by admins.
[p]autoreact
This cog displays the number of users banned in the guild with a random selection from a list of messages.
[p]bancount
- Displays the total ban count using a randomly selected message.[p]bancount list
- Lists all the messages that can be used in the guild.[p]bancount add <message>
- Add a message to the guild list. Use$ban
to insert the ban count in the message.[p]bancount remove <message index>
- Deletes (by index, from the list command) the message from the guild list.
This cog is an upgraded version of the built-in ping command showing some latency information. It will override the built-in ping command when loaded, but reinstate it once when loaded.
It was inspired by Vexed01's AnotherPingCog, but it's slimmed down and not as snazzy.
[p]ping
Converts any unit to any another unit.
[p]convert
Allows moderators to send/edit messages from the bot.
[p]msg create
[p]msg edit
This cog allows you to enforce certain characteristics on a channel.
[p]enforcer
There are numerous attributes than can be used to restrict messages/content into a channel.
While some attributes are available in discord via role-based permissions, sometimes a bot may be better off enforcing content in a pinch.
[p]enforcer configure <channel> <attribute> [value]
Example:
[p]enforcer configure #channel enabled true
Attribute | Type | Description |
---|---|---|
enabled |
bool |
Whether to enable enforcements on a channel |
minchars |
int |
The minimum number of characters a message must contain to be allowed into the channel |
maxchars |
int |
The maximum number of characters a message may contain to be allowed into the channel |
notext |
bool |
The sent message must have no text, i.e. should be an image-only message |
requiremedia |
bool |
The sent message must contain an attached image |
nomedia |
bool |
The sent message must not contain an attached image |
minimumguildage |
int |
How old a server member must be part of the guild, in seconds, before they are able to contribute to the channel |
minimumdiscordage |
int |
How old a member's discord account must be, in seconds, before they are able to contribute to the channel |
An example enforcement would be a channel to show off server pictures. In which case, you could allow members to post a set of images with a description of their setup.
In which case, the following would be appropriate
[p]enforcer logchannel #admin-log
[p]enforcer configure #serverpics requiremedia true
[p]enforcer configure #serverpics minimumguildage 600
[p]enforcer configure #serverpics minchars 20
[p]enforcer configure #serverpics maxchars 300
[p]enforcer configure enabled true
This cog allows users to feed each other.
This cog allows users to send google links to each other.
[p]google <query>
This cog answers the question "Is It Read-Only Friday?". The user can optionally specify a UTC offset. Includes read-only December for the users with annual change freezes.
[p]isitreadonlyfriday [offset=0]
[p]isitreadonlydecember [offset=0]
Also availble as a slash command.
This cog allows users to display complex mathematical information using LaTeX renderings.
[p]latex <latex statement>
This cog converts a string of letters/numbers into large emote letters ("regional indicators") or numbers.
-raw
flag can be used to output raw emote code.
[p]letters I would like this text as emotes 123
[p]letters -raw I would like this text as raw emote code 123
This cog generates messages based on markov chains generated per-user.
User messages will never be analysed unless the user explicitly opts in.
It must also be enabled per-channel: [p]markov channelenable
Modified version of CrunchBangDev's cog.
[p]markov generate
- Generate text based on user language models.[p]markov enable
- Allow the bot to model your messages and generate text.[p]markov disable
- Disallow the bot from model;ing your messages or generating text.[p]markov mode
- Set the tokenization mode for model building.[p]markov depth
- Set the modelling depth (the "n" in "ngrams").[p]markov show_user
- Show your current settings and models, or those of another user.[p]markov delete
- Delete a specific model from your profile.[p]markov reset
- Remove all language models from your profile.
[p]markov show_guild
- Show current guild settings.[p]markov channelenable
- Allow language modelling on messages in a given channel.[p]markov channeldisable
- Disallow language modelling on messages in a given channel.
[p]markov show_global [guild_id]
- Show global summary info or summary ofguild_id
.
Manage notes and warnings against users.
[p]notes
[p]warnings
Notes can be used for long-term storage information of problematic users or for future reference.
When listing the notes of a user, the warnings will be prioritised as they will be deemed more important.
It is possible to add notes to a user who has left or not yet joined. Notes are stored against a user's ID and do not require the user to be part of the server.
Deleting a note does not actually delete the note. It simply marks it in the datastore as deleted and does not show it in normal use. This can allow future recovery of notes (using the restore
subcommand) if a bad party is attempting to wipe existing notes.
Notes and warnings can be edited using the edit
subcommand.
This cog allows users to check the size of their penis.
[p]penis <user>
This cog automatically deletes any messages containing suspected phishing/scam links. This information is sourced from phish.sinking.yachts
This cog will purge users that hold no roles as a way to combat accounts being created and left in an un-verified state.
[p]purge
-
[p]purge schedule "0 */6 * * *"
- It is possible to run the purge on a schedule. By default, it is disabled, but configured for0 */6 * * *
which is a crontab for every 6 hours. E.g. will run at00:00
,06:00
,12:00
and18:00
every day. -
[p]purge minage 5
It will attempt to prune users that hold no roles, that have been part of the server for at least<minage>
days (default to 5).<minage>
can be altered to fit your server's requirements to ensure that people that joined but never verified, are not clogging up mention lists and to keep activity ratios high.
By default, purge's schedule is disabled and must be enabled to prune unverified users.
-
[p]purge simulate
- It's possible to do a simulated purge by running[p]purge simulate
. This will retrieve the list of users it would prune, had it run as normal. This allows moderators to test out configuration without performing any permanent actions. -
[p]purge exclude @Sneezey#2695
- If a user does not hold any roles for any reason, but you wish to exclude them from the purge, it is possible to add this user to theexclude
list. This action can also be undone with theinclude
subcommand. -
[p]purge status
- To check how many users have been purged any other configuration items, the status command allows you to see the values in an easy-to-see embed.
This cog will allow members to add quotes to the quotes channel easily.
[p]quote
Allows roles to be applied and removed using reactions.
[p]reactrole
This cog will allow members to send a report into a channel where it can be reviewed and actioned upon by moderators.
-
[p]reports logchannel #admin-log
- For reports to be able to be taken, a log channel must be set which will receive an embed upon a user using the report command. -
[p]reports channel [allow|deny] [channel]
- Disallow thereport
/emergency
commands to be used in certain channels -
[p]reports confirm [true|false]
- When a report is issued, this sets whether the bot will DM the user with confirmation or not -
[p]report [message]
- A report can be sent to the logchannel for any moderators to see and action upon when they are ready. -
[p]emergency [message]
- An emergency can be requested which will ping all members in the configured logchannel if they are online.
Allows you to view info on a role
[p]roleinfo <role>
Send unhandled errors and performance metrics to sentry.
Configure Sentry DSN using [p]set api sentry dsn,https://[email protected]/9
, then load the Cog [p]load sentry
.
[p]sentry get_log_level
- Get the current log level.[p]sentry set_log_level
- Set the desired log level, must be one oferror
,warning
,info
ordebug
. Does not require a reload.[p]sentry get_env
- Returns the currently configured Sentry environment.[p]sentry set_env
- Set the currently configured Sentry environment. Requires a reload of the cog.[p]sentry test
- Raise a test exception to test the Sentry connection.
Allow user-generated stored messages to be triggered upon configurable tags. Aliases can also be created to make accessing information even quicker. Users can transfer tag ownership between themselves and even claim ownership of abandoned tags. Ever use of a tag or alias is tracked. Same with ownership transfers of any kind. Statistics and searching have not yet been implemented.
[p]tag <tag>
- Triggers the specified tag.[p]tag search <query>
- Searches for a tag or alias.[p]tag create <tag> <content>
- Creates the specified tag which will reply with the provided content when triggered.[p]tag stats [user]
- Provides general stats about the tag system, or if a user is provided, about that user.[p]tag info <tag>
- Provides info about the tag such as its creator, date of creation, etc.[p]tag edit <tag> <content>
- Updates the content of the specified tag.[p]tag delete <tag>
- Deletes the specified tag.[p]tag claim <tag>
- Allows the runner to claim ownership of the tag if the current owner is not in the guild.[p]tag transfer <tag> <user>
- Transfers ownership of the specified tag to the specified user.[p]tag list [user]
- Lists all tags and aliases, or just those for the specified user.[p]tag alias create <alias> <tag>
- Creates the specified alias to the specified tag.[p]tag alias delete <alias>
- Deletes the specified alias.- (struck commands are disabled, pending feature review.)
This cog exposes a HTTP endpoint for exporting guild metrics in Prometheus format.
[p]prom_export set_port <port>
- Set the port the HTTP server should listen on[p]prom_export set_address <address>
- Sets the bind address (IP) of the HTTP server[p]prom_export set_poll_interval <interval>
- Set the metrics poll interval (seconds)[p]prom_export config
- Show the current running config
Manage the timeout status of users.
Run the command to add a user to timeout, run it again to remove them. Append a reason if you wish: [p]timeout @someUser said a bad thing
If the user is not in timeout, they are added. If they are in timeout, they are removed.
All of the member's roles will be stripped when they are added to timeout, and re-added when they are removed.
[p]timeout <user> [reason]
- Add/remove a user from timeout, optionally specifying a reason.[p]timeoutset list
- Print the current configuration.[p]timeoutset role <role name>
- Set the timeout role.[p]timeoutset report <bool>
- Set whether timeout reports should be logged or not.[p]timeoutset logchannel <channel>
- Set the log channel.
Shows the current channel topic as a message in the channel.
Channel topics are notoriously hard for users to see. It's in a not so obvious place in the desktop UI and it's not possible to see in the mobile UI unless you are looking at the memberlist. Topic allows users to easily view the current channel topic or use it to remind other users in the channel what the topic currently is.
[p]topic
- Prints the current channel topic. Output message format:#channel: topic
/topic
- Same as above but implemented as a discord slash command.
This cog will allow users to prove they're not a bot by having to read rules and complete an action. They will then be given the verified role if they can complete this.
[p]verify block <user>
- Add the specified user to the verification blocklist.[p]verify channel <channel>
- Set the channel in which the cog listens for verification attemps.[p]verify logchannel <channel>
- Set the channel in which the cog logs verification attemps.[p]verify message <message>
- Set the verification string (e.g.I agree to the rules
.[p]verify role <role>
- Set the role to which users are added upon successful verification.
Further configuration options can be seen with [p]verify help
This cog allows users to look at xkcd comics
[p]xkcd <comicnumber>
All code in this repository is licensed under the GNU General Public License version 3.
Copyright (c) 2018-2023 tigattack, contributors and original authors.
The CI will fail unless your code is PEP8 compliant.
pip install -r requirements-ci.txt
isort . # This will fix the order of imports
black . # This will auto-format and fix a lot of common mistakes
pylint * # This will show general pep8-violations
If you use VSCode you can use the tasks integrated into the repo to locally run the same tasks as our CI
When suggesting changes, please open an issue so it can be reviewed by the team who can then suggest how and if the idea is to be implemented.
When submitting changes, please create a pull request targeting the main branch.