aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar TizzySaurus <[email protected]>2021-11-06 10:56:09 +0000
committerGravatar GitHub <[email protected]>2021-11-06 10:56:09 +0000
commit1302632c39469a124e85e6b43c5278526874ce5e (patch)
tree7fae7d103dee60f1c5b294b9fd291ae05297c59c
parentMerge pull request from GHSA-j8c3-8x46-8pp6 (diff)
Only re-run filters in `on_message_update` if contents/attachments changed (#1937)
-rw-r--r--bot/exts/filters/filtering.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py
index f05b1d00b..79b7abe9f 100644
--- a/bot/exts/filters/filtering.py
+++ b/bot/exts/filters/filtering.py
@@ -189,8 +189,16 @@ class Filtering(Cog):
"""
Invoke message filter for message edits.
- If there have been multiple edits, calculate the time delta from the previous edit.
+ Also calculates the time delta from the previous edit or when message was sent if there's no prior edits.
"""
+ # We only care about changes to the message contents/attachments and embed additions, not pin status etc.
+ if all((
+ before.content == after.content, # content hasn't changed
+ before.attachments == after.attachments, # attachments haven't changed
+ len(before.embeds) >= len(after.embeds) # embeds haven't been added
+ )):
+ return
+
if not before.edited_at:
delta = relativedelta(after.edited_at, before.created_at).microseconds
else:
@@ -341,7 +349,7 @@ class Filtering(Cog):
await self.notify_member(msg.author, _filter["notification_msg"], msg.channel)
# If the message is classed as offensive, we store it in the site db and
- # it will be deleted it after one week.
+ # it will be deleted after one week.
if _filter["schedule_deletion"] and not is_private:
delete_date = (msg.created_at + OFFENSIVE_MSG_DELETE_TIME).isoformat()
data = {