aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar bendiller <[email protected]>2019-10-17 14:08:13 -0600
committerGravatar bendiller <[email protected]>2019-10-17 14:08:13 -0600
commit0d164adf6ac13611f1fc66825998d20d26f240ac (patch)
treef5834c3fd25ddec4aa7ea3d652861cf1c1f19ff9
parentImprove code readability and provide early exit from loop (diff)
Address reviewer request
-rw-r--r--bot/cogs/antimalware.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/cogs/antimalware.py b/bot/cogs/antimalware.py
index 2ef61e8ad..b8c12accb 100644
--- a/bot/cogs/antimalware.py
+++ b/bot/cogs/antimalware.py
@@ -20,13 +20,14 @@ class AntiMalware(Cog):
rejected_attachments = False
detected_pyfile = False
for attachment in message.attachments:
- if not attachment.filename.lower().endswith(tuple(AntiMalwareConfig.whitelist)):
- rejected_attachments = True
if attachment.filename.lower().endswith('.py'):
detected_pyfile = True
break # Other detections irrelevant because we prioritize the .py message.
+ if not attachment.filename.lower().endswith(tuple(AntiMalwareConfig.whitelist)):
+ rejected_attachments = True
+ break
- if rejected_attachments:
+ if detected_pyfile or rejected_attachments:
# Send a message to the user indicating the problem (with special treatment for .py)
author = message.author
if detected_pyfile: