diff options
author | 2019-10-17 14:08:13 -0600 | |
---|---|---|
committer | 2019-10-17 14:08:13 -0600 | |
commit | 0d164adf6ac13611f1fc66825998d20d26f240ac (patch) | |
tree | f5834c3fd25ddec4aa7ea3d652861cf1c1f19ff9 | |
parent | Improve code readability and provide early exit from loop (diff) |
Address reviewer request
-rw-r--r-- | bot/cogs/antimalware.py | 7 |
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: |