Skip to content

Commit

Permalink
Merge pull request #310 from practical-python-org/fix/invite_spam_and…
Browse files Browse the repository at this point in the history
…_automod_spam_fixes

Fix/invite spam and automod spam fixes
  • Loading branch information
Xarlos89 authored Nov 29, 2023
2 parents dc46f7d + 3adaac3 commit 765b2e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/zorak/cogs/admin/admin_automod_spam_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ async def on_message(self, message):
# Dont catch Zorak
if message.author.bot:
return
# Dont care about DM channels
if isinstance(message.channel, discord.DMChannel):
return

# new speaker. Welcome to auto mod.
if message.author.id not in self.records:
Expand Down
9 changes: 6 additions & 3 deletions src/zorak/cogs/admin/moderation_invites.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def log_message(arg_message):
author = arg_message.author
embed = discord.Embed(
title="<:red_circle:1043616578744357085> Invite removed",
description=f"Posted by {arg_message.author}\nIn {arg_message.channel.mention}",
description=f"Posted by {arg_message.author}\nIn {'a DM.' if isinstance(arg_message.channel, discord.DMChannel) else arg_message.channel.mention}",
color=discord.Color.dark_red(),
timestamp=datetime.utcnow(),
)
Expand All @@ -70,8 +70,8 @@ def embed_warning(arg_message):
embed = discord.Embed(
title="<:x:1055080113336762408> External Invites are not allowed here!",
description=f"{arg_message.author}, your message was removed "
f"because it contained an external invite.\nIf this "
f"was a mistake, contact the @staff",
f"because it contained an external invite.\nIf this "
f"was a mistake, contact the @staff",
color=discord.Color.dark_red(),
timestamp=datetime.utcnow(),
)
Expand All @@ -87,6 +87,9 @@ def check_for_admin_override(arg_message):
return any(role.id in self.bot.server_settings.admin_roles.values() for role in message.author.roles)

if is_invite(txt):
if isinstance(message.channel, discord.DMChannel):
return

if not check_for_admin_override(txt):
logs_channel = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"])
await logs_channel.send(embed=log_message(message))
Expand Down

0 comments on commit 765b2e6

Please sign in to comment.