Skip to content

A simple and efficient spam filter built to be used in discord bots made with any fork of discord.py!

License

Notifications You must be signed in to change notification settings

DorianAarno/SpamFilter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spam Filter

A simple and efficient spam filter built to be used in discord bots made with any fork of discord.py!

Installation

You can use pip to install this library.

pip install discordpy-antispam

Usage

Quickstart Guide

from SpamFilter import AntiSpam

@bot.event
async def on_message(msg):
  spam_check = await AntiSpam().check(bot, msg.channel, msg.author)

Detailed Guide

from SpamFilter import AntiSpam

dictionary_check = True # Default is False, DO NOT USE THIS IF YOUR SERVER IS MULTI-LINGUAL, Checks if any word in the message is present in english dictionary.
timer_check = True # Default is True, Checks if a member has sent more than 5 messages within 15 seconds, if yes, 6th message is marked as spam.
content_check = True # Default is True, Checks the message's content and if a letter whose occurance in the content is highest covers more than 85% of the content, it marks the message as spam.
history_check = True # Default is True, Checks if the message's content is duplicate of the previous message.

@bot.event
async def on_message(msg):
  spam_check = await AntiSpam(
    dictionary = dictionary_check,
    timer = timer_check,
    content = content_check,
    history = history_check
  ).check(bot, msg.channel, msg.author)

Example

You may view implementation of this library in PointsBot.

Notes

  • This library has only been tested with discord-disnake.
  • Your bot needs to have access to message content.

Contributing

  • Fork the repository.
  • Add your desired change or filter.
  • Open pull request.
  • Issues are welcome.
  • Consider giving this repository a ⭐, It is highly appreciated!

License

This repository has been made available via MIT License.