Skip to content

Commit f4c835b

Browse files
committed
Fix crosspost alert message deletion logic in 'anti_crosspost' extension
1 parent 5ebbb9f commit f4c835b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pcbot/exts/anti_crosspost.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,15 @@ async def crosspost_cmp(message: discord.Message, other: discord.Message) -> boo
8181

8282
if not have_content and (message.content or other.content):
8383
return False
84-
elif not have_attachments and (
85-
message.attachments or other.attachments
86-
):
84+
elif not have_attachments and (message.attachments or other.attachments):
8785
return False
8886
elif have_content and have_attachments:
8987
return similarity_score > 0.80 and matching_attachments
9088
elif have_content:
9189
return similarity_score > 0.80
9290
elif have_attachments:
9391
return matching_attachments
94-
92+
9593
return False
9694

9795

@@ -244,11 +242,13 @@ async def on_message_delete(self, message: discord.Message):
244242
user_cache["message_to_alert"].pop(message.id)
245243
)
246244
break
247-
# Mark all alert messages for this crosspost group as stale if the group
245+
246+
# Mark last alert message for this crosspost group as stale if the group
248247
# has only one message
249-
if len(messages) == 1:
250-
stale_alert_message_ids.extend(user_cache["message_to_alert"].values())
251-
user_cache["message_to_alert"].clear()
248+
if len(messages) == 1 and messages[0].id in user_cache["message_to_alert"]:
249+
stale_alert_message_ids.append(
250+
user_cache["message_to_alert"].pop(messages[0].id)
251+
)
252252

253253
# Delete stale alert messages
254254
for alert_message_id in stale_alert_message_ids:

0 commit comments

Comments
 (0)