Message intent justification for Python-based Discord bots
Project description
Technically Automod
Message intent justification for Python-based discord bots
technically-automod is an automod cog for major Python-based Discord API frameworks (Discord.py, Disnake, Nextcord).
Installing
technically-automod can be installed with the command
# Linux
python3 -m pip install -U technically-automod
# Windows
python -m pip install -U technically-automod
To install the development version of the library directly from source:
$ git clone https://github.com/nwunderly/technically-automod
$ cd technically-automod
$ python3 -m pip install -U .
Quickstart
Load the extension:
# discord.py
await bot.load_extension("technically_automod")
# disnake & nextcord
bot.load_extension("technically_automod")
Loading the extension
You can load technically-automod the same way you load any other extension. The library will automatically detect which Discord API library you have installed, and choose the correct extension to load.
# discord.py
await bot.load_extension("technically_automod")
# disnake & nextcord
bot.load_extension("technically_automod")
If you have multiple Discord API libraries installed, the above method will raise an ImportError exception. If this happens, you should load the extension based on the library you're using:
# discord.py
await bot.load_extension("technically_automod.discordpy")
# disnake
bot.load_extension("technically_automod.disnake")
# nextcord
bot.load_extension("technically_automod.nextcord")
You can also add the Cog manually:
# Auto-detect library
from technically_automod import TechnicallyAutomodCog
await bot.add_cog(TechnicallyAutomodCog(bot)) # if using discord.py
bot.add_cog(TechnicallyAutomodCog(bot)) # if using disnake or nextcord
# discord.py
from technically_automod import DiscordpyAutomodCog
await bot.add_cog(DiscordpyAutomodCog(bot))
# disnake
from technically_automod import DisnakeAutomodCog
bot.add_cog(DisnakeAutomodCog(bot))
# nextcord
from technically_automod import NextcordAutomodCog
bot.add_cog(NextcordAutomodCog(bot))
Configuration
When loaded, the automod cog will look for a file called "config.json" in the Python process's working directory. An example config file is provided in this repository.
The config should be structured as a list of rules, where each rule consists of a name, a rule type, actions to perform on match, and (if necessary) a list of items to match on.
Disable Automod
Automod will do nothing if:
- There is no
config.jsonfile. config.jsonis empty.config.jsoncontains an empty json list:[]
Rule Types
The type field should be a string defining the rule type.
- Rule type
phishingwill use the FishFish database to detect phishing links. The extension will update the phishing domain list every hour if the configuration contains a phishing rule. - Rule type
wordswill match whole words in the message content. - Rule type
substringwill detect the matches anywhere in the message content, including in the middle of words. - Rule type
regexwill use Python'sre.searchfunction to find regex pattern matches in the message content.
Match List
The match field in each rule should be a list of strings defining the words, substrings,
or regex patterns to match on. The phishing rule should not have a match field.
Actions
The actions field should be a list of actions to perform if a match is detected. The options are:
delete- Delete the message.kick- Kick the user from the server.ban- Ban the user from the server.
Note: if "kick" and "ban" are both listed, the one listed first will be performed and the next will be ignored.
Examples
Example config.json file:
[
{
"name": "Phishing Detection",
"type": "phishing",
"actions": ["delete", "kick"]
},
{
"name": "Bad Word Detection",
"type": "words",
"match": ["heck", "frick"],
"actions": ["delete"]
},
{
"name": "Brainrot Detecton",
"type": "substring",
"match": ["67"],
"actions": []
},
{
"name": "Spam Detection",
"type": "regex",
"match": ["(?:\w+){30,}"],
"actions": ["delete"]
}
]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file technically_automod-0.1.0.tar.gz.
File metadata
- Download URL: technically_automod-0.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/7.0.9-76070009-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b796dc569a84352d24bdc02170e8533882218828d08bd314e99c95b4beeb695
|
|
| MD5 |
8da84bc2cd75629bad1ddee63a92c257
|
|
| BLAKE2b-256 |
44bb855d6764fc8831e6c2e31465d23d18e51ae2c471af28075dfab180ef04ee
|
File details
Details for the file technically_automod-0.1.0-py3-none-any.whl.
File metadata
- Download URL: technically_automod-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/7.0.9-76070009-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0d5948e89de2f72fabab14d87e527fb75e07031cb509335b5a47bb6ac6c4d18
|
|
| MD5 |
ab7a99f3a0d9adf6cb8b5d3ae2c296d4
|
|
| BLAKE2b-256 |
3530413f5b34696be04726829e3fa70d34efcc35d434df8b980c8557214c5a14
|