aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar TizzySaurus <[email protected]>2021-10-04 21:00:59 +0100
committerGravatar Izan <[email protected]>2021-10-05 09:35:42 +0100
commit269ab7e1a0f35c4ecf14bffba93ab1695841364b (patch)
treec8356f97b62b3588f058821cf2b4975a154214e1
parentMerge pull request #1853 from python-discord/catch-403-from-Typing-calls (diff)
Improvements to anti-spam log message
- Removed redundant f-string - Made it so that messages with attachments will *always* upload to the log site. - Made it so that truncates messages will also upload to the paste site, for full viewing. - Fixed a previously unnoticed bug where truncating didn't account for extra characters of the ellipses.
-rw-r--r--bot/exts/filters/antispam.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/bot/exts/filters/antispam.py b/bot/exts/filters/antispam.py
index 70c1168bf..dc8d24bba 100644
--- a/bot/exts/filters/antispam.py
+++ b/bot/exts/filters/antispam.py
@@ -83,7 +83,11 @@ class DeletionContext:
)
# For multiple messages or those with excessive newlines, use the logs API
- if len(self.messages) > 1 or 'newlines' in self.rules:
+ if any((
+ len(self.messages) > 1,
+ self.messages[0].attachments,
+ self.messages[0].count('\n') > 15
+ )):
url = await modlog.upload_log(self.messages.values(), actor_id, self.attachments)
mod_alert_message += f"A complete log of the offending messages can be found [here]({url})"
else:
@@ -93,9 +97,11 @@ class DeletionContext:
remaining_chars = 4080 - len(mod_alert_message)
if len(content) > remaining_chars:
- content = content[:remaining_chars] + "..."
+ url = await modlog.upload_log([message], actor_id, self.attachments)
+ log_site_msg = f"The full message can be found [here]({url})"
+ content = content[:remaining_chars - (3 + len(log_site_msg))] + "..."
- mod_alert_message += f"{content}"
+ mod_alert_message += content
*_, last_message = self.messages.values()
await modlog.send_log_message(