Skip to main content

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:

  1. There is no config.json file.
  2. config.json is empty.
  3. config.json contains an empty json list: []

Rule Types

The type field should be a string defining the rule type.

  1. Rule type phishing will 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.
  2. Rule type words will match whole words in the message content.
  3. Rule type substring will detect the matches anywhere in the message content, including in the middle of words.
  4. Rule type regex will use Python's re.search function 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:

  1. delete - Delete the message.
  2. kick - Kick the user from the server.
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

technically_automod-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

technically_automod-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

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

Hashes for technically_automod-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b796dc569a84352d24bdc02170e8533882218828d08bd314e99c95b4beeb695
MD5 8da84bc2cd75629bad1ddee63a92c257
BLAKE2b-256 44bb855d6764fc8831e6c2e31465d23d18e51ae2c471af28075dfab180ef04ee

See more details on using hashes here.

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

Hashes for technically_automod-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0d5948e89de2f72fabab14d87e527fb75e07031cb509335b5a47bb6ac6c4d18
MD5 ab7a99f3a0d9adf6cb8b5d3ae2c296d4
BLAKE2b-256 3530413f5b34696be04726829e3fa70d34efcc35d434df8b980c8557214c5a14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page