From 43d330f5e8499eafc471613c9b866616b07b6e0b Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Fri, 3 Aug 2018 19:53:12 +0200 Subject: Add channel & role whitelist to `AntiSpam`. --- bot/cogs/antispam.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bot/cogs/antispam.py b/bot/cogs/antispam.py index 04b030889..21161ff04 100644 --- a/bot/cogs/antispam.py +++ b/bot/cogs/antispam.py @@ -9,7 +9,11 @@ from discord import Member, Message, Object, TextChannel from discord.ext.commands import Bot from bot import rules -from bot.constants import AntiSpam as AntiSpamConfig, Channels, Colours, Guild as GuildConfig, Icons +from bot.constants import ( + AntiSpam as AntiSpamConfig, Channels, + Colours, Guild as GuildConfig, + Icons, Roles +) from bot.utils.time import humanize as humanize_delta @@ -27,6 +31,13 @@ RULE_FUNCTION_MAPPING = { 'newlines': rules.apply_newlines, 'role_mentions': rules.apply_role_mentions } +WHITELISTED_CHANNELS = ( + Channels.admin, Channels.announcements, Channels.big_brother_logs, + Channels.devalerts, Channels.devlog, Channels.devtest, + Channels.helpers, Channels.message_log, + Channels.mod_alerts, Channels.modlog, Channels.staff_lounge +) +WHITELISTED_ROLES = (Roles.owner, Roles.admin, Roles.moderator, Roles.helpers) class AntiSpam: @@ -39,7 +50,12 @@ class AntiSpam: self.muted_role = Object(role_id) async def on_message(self, message: Message): - if message.guild.id != GuildConfig.id or message.author.bot: + if ( + message.guild.id != GuildConfig.id + or message.author.bot + or message.channel.id in WHITELISTED_CHANNELS + or message.author.top_role.id in WHITELISTED_ROLES + ): return # Fetch the rule configuration with the highest rule interval. -- cgit v1.2.3