diff options
| author | 2018-08-06 16:29:15 +0000 | |
|---|---|---|
| committer | 2018-08-06 16:29:15 +0000 | |
| commit | 4ed20ebdca99b77642fd4b693859c6cb2a1c06ad (patch) | |
| tree | e3a4b59a56986dcb08e348f3fdc8a3f783a658ec | |
| parent | Merge branch 'enhancement/bump-pika-logging-level' into 'master' (diff) | |
| parent | Add channel & role whitelist to `AntiSpam`. (diff) | |
Merge branch 'enhancement/add-antispam-channel-and-role-whitelist' into 'master'
Add a channel & role whitelist to `AntiSpam` cog.
See merge request python-discord/projects/bot!50
| -rw-r--r-- | bot/cogs/antispam.py | 20 |
1 files 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. |