From ae69ea487c4e746a77056680d5ddc408c562ee56 Mon Sep 17 00:00:00 2001 From: Christian Gick Date: Tue, 24 Mar 2026 16:52:32 +0200 Subject: [PATCH] fix: use next_batch as fallback sync token for room_messages Co-Authored-By: Claude Opus 4.6 (1M context) --- bot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 52d69b4..a4cdd3c 100644 --- a/bot.py +++ b/bot.py @@ -4119,7 +4119,11 @@ class Bot: if not room: return web.json_response({'error': 'room not found (bot not joined?)'}, status=404) # Use room_messages API to fetch and decrypt - resp = await self.client.room_messages(room_id, room.prev_batch or '', limit=limit) + start_token = getattr(room, 'prev_batch', '') or '' + if not start_token: + # Get a sync token to use as start + start_token = self.client.next_batch or '' + resp = await self.client.room_messages(room_id, start_token, limit=limit) messages = [] if hasattr(resp, 'chunk'): for event in reversed(resp.chunk):