aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar dementati <[email protected]>2021-11-07 07:46:38 +0100
committerGravatar GitHub <[email protected]>2021-11-07 07:46:38 +0100
commit2f9c96c104fd9a93869e79f9ffd4d75e58ef7b84 (patch)
tree11c74cd09e88337324562667b59bd5b9413165d5
parentMerge branch 'main' into feature/1903/fix-pin-inconsistency (diff)
parentOnly re-run filters in `on_message_update` if contents/attachments changed (#... (diff)
Merge branch 'main' into feature/1903/fix-pin-inconsistency
-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 = {