This commit is contained in:
2026-03-16 20:09:10 +00:00
parent b2a9f74f59
commit 868d2dfc18
+15 -3
View File
@@ -221,11 +221,23 @@ def chat_message_watcher(reddit):
except Exception as e:
print(f"[CHAT] Error loading processed message IDs: {e}")
# Get the latest message timestamp at startup
last_seen_timestamp = None
try:
# Fetch the most recent message (limit=1)
latest = list(reddit.inbox.all(limit=1))
if latest and hasattr(latest[0], 'created_utc'):
last_seen_timestamp = latest[0].created_utc
print(f"[CHAT] Last seen message timestamp at startup: {last_seen_timestamp}")
except Exception as e:
print(f"[CHAT] Error fetching latest message timestamp: {e}")
while True:
try:
for message in reddit.inbox.stream():
# Skip if no ID or already processed
if not hasattr(message, 'id') or message.id in processed_message_ids:
# Skip if no ID, already processed, or message is older than startup
if (not hasattr(message, 'id') or message.id in processed_message_ids or
(last_seen_timestamp is not None and hasattr(message, 'created_utc') and message.created_utc <= last_seen_timestamp)):
continue
# Mark as processed
@@ -259,7 +271,7 @@ def chat_message_watcher(reddit):
message.reply(reply_text)
print(f"[CHAT] Replied to message {message.id}")
except Exception as e:
print(f"[CHAT] Error replying to message {message.id}: {e}")
print(f"[CHAT] Error replying to message {message.id}: {message.id}: {e}")
else:
print(f"[CHAT] Non-moderator '{author}' attempted reload-config (ignored)")
except Exception as e: