From c15e9bbd7c928a4bd50436448014b185282476c6 Mon Sep 17 00:00:00 2001 From: zwitschi Date: Sun, 10 May 2026 11:32:24 +0200 Subject: [PATCH] fix: improve logging and pagination logic in delete_old_messages function --- main.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 7a68552..4505a40 100644 --- a/main.py +++ b/main.py @@ -539,17 +539,11 @@ def delete_old_messages(minutes: int = 6) -> None: headers, DISCORD_CHANNEL_ID, webhook_id, author_id, cutoff, last_message_id ) - # Exit loop if no more messages to delete + # Stop scanning when a page has no eligible messages to delete. + # Continuing pagination here can walk indefinitely through history. if not delete_list: if deleted_count == 0: - if next_last_message_id is None or next_last_message_id == last_message_id: - logging.info("No messages to delete.") - break - else: - logging.info( - "No messages deleted in this batch, but more messages may exist... Continuing pagination.") - last_message_id = next_last_message_id - continue + logging.info("No messages to delete.") else: logging.info("No more messages to delete.") break