Skip to content

Commit

Permalink
Add anti invite spam measures (FO-nTTaX#37)
Browse files Browse the repository at this point in the history
* add bad words

* add comment

* add anti invite spam measures

* remove trailing `/` for `discord.gg`

* adjust text

* exclude bot
  • Loading branch information
hjpalpha authored Jan 24, 2023
1 parent 0ae4cfc commit fe6f31d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
51 changes: 51 additions & 0 deletions ftsbot/cogs/antispam.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from discord import app_commands
from discord.ext import commands
from ftsbot import config
from ftsbot import data
from ftsbot.ui.reportform import reportform


Expand Down Expand Up @@ -83,6 +84,56 @@ async def on_message(
)
# delete flagged message
await message.delete()
elif 'discord.gg' in message.content.lower():
has_bad_word = False
for bad_word in data.bad_words:
if bad_word in message.content.lower():
has_bad_word = True
break
has_exception_role = False
for role in message.author.roles:
if role.name in [
'Discord Admins',
'Liquipedia Employee',
'Administrator',
'Bot',
]:
has_exception_role = True
break
if has_bad_word and not has_exception_role:
# give muted role
mutedrole = discord.utils.get(message.guild.roles, name='Muted')
await message.author.add_roles(mutedrole)
# post message in staff channel
reporttarget = self.bot.get_channel(config.reporttarget)
time = message.created_at
await reporttarget.send(
embed=discord.Embed(
title=(
'Muted for potential discord invite link spam - '
+ message.author.mention + ' in ' + message.channel.mention
+ ' on ' + str(time)[:-7] + ' UTC:'
),
color=discord.Color.blue(),
description=(
message.content
# Workaround for mentions not working in embed title on windows
+ '\n\nsource: ' + message.author.mention + ' in ' + message.channel.mention
)
)
)
# post response message so that user knows what is going on
await message.channel.send(
embed=discord.Embed(
colour=discord.Colour(0xff0000),
description=(
message.author.mention + ' you have been muted due to potential discord invite spam. '
+ 'This is a spam bot prevention. Admins will review it at their earliest convenience.'
)
)
)
# delete flagged message
await message.delete()
if 'liquidpedia' in message.content.lower():
await message.channel.send(
embed=discord.Embed(
Expand Down
15 changes: 15 additions & 0 deletions ftsbot/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,18 @@
'R6 Predictions',
'Templates',
]

# Words regularly used in invite spams
bad_words = [
'nudde',
'nude',
'sex',
's3x',
'seex',
'tiktok',
'18+',
'kiss',
'onlyfans',
'nft',
'crypto',
]

0 comments on commit fe6f31d

Please sign in to comment.