aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Xithrius <[email protected]>2021-06-05 23:46:49 -0700
committerGravatar Xithrius <[email protected]>2021-06-05 23:46:49 -0700
commita71d37be61baf5b9f157f430d59081ca881689d5 (patch)
tree9c5bc7725b9d166d187db22aa671f36e729e3644
parentMerge pull request #1587 from RohanJnr/voice_ver_dm (diff)
Allowed text format warning to have multiple formats.
-rw-r--r--bot/exts/filters/antimalware.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/bot/exts/filters/antimalware.py b/bot/exts/filters/antimalware.py
index 26f00e91f..f8d303389 100644
--- a/bot/exts/filters/antimalware.py
+++ b/bot/exts/filters/antimalware.py
@@ -15,9 +15,11 @@ PY_EMBED_DESCRIPTION = (
f"please use a code-pasting service such as {URLs.site_schema}{URLs.site_paste}"
)
+TXT_LIKE_FILES = {".txt", ".csv", ".json"}
TXT_EMBED_DESCRIPTION = (
"**Uh-oh!** It looks like your message got zapped by our spam filter. "
- "We currently don't allow `.txt` attachments, so here are some tips to help you travel safely: \n\n"
+ "We currently don't allow `{blocked_extension_str}` attachments, "
+ "so here are some tips to help you travel safely: \n\n"
"• If you attempted to send a message longer than 2000 characters, try shortening your message "
"to fit within the character limit or use a pasting service (see below) \n\n"
"• If you tried to show someone your code, you can use codeblocks \n(run `!code-blocks` in "
@@ -70,10 +72,13 @@ class AntiMalware(Cog):
if ".py" in extensions_blocked:
# Short-circuit on *.py files to provide a pastebin link
embed.description = PY_EMBED_DESCRIPTION
- elif ".txt" in extensions_blocked:
+ elif extensions := TXT_LIKE_FILES.intersection(extensions_blocked):
# Work around Discord AutoConversion of messages longer than 2000 chars to .txt
cmd_channel = self.bot.get_channel(Channels.bot_commands)
- embed.description = TXT_EMBED_DESCRIPTION.format(cmd_channel_mention=cmd_channel.mention)
+ embed.description = TXT_EMBED_DESCRIPTION.format(
+ blocked_extension_str=extensions.pop(),
+ cmd_channel_mention=cmd_channel.mention
+ )
elif extensions_blocked:
meta_channel = self.bot.get_channel(Channels.meta)
embed.description = DISALLOWED_EMBED_DESCRIPTION.format(