fix: use next_batch as fallback sync token for room_messages
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
6
bot.py
6
bot.py
@@ -4119,7 +4119,11 @@ class Bot:
|
|||||||
if not room:
|
if not room:
|
||||||
return web.json_response({'error': 'room not found (bot not joined?)'}, status=404)
|
return web.json_response({'error': 'room not found (bot not joined?)'}, status=404)
|
||||||
# Use room_messages API to fetch and decrypt
|
# 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 = []
|
messages = []
|
||||||
if hasattr(resp, 'chunk'):
|
if hasattr(resp, 'chunk'):
|
||||||
for event in reversed(resp.chunk):
|
for event in reversed(resp.chunk):
|
||||||
|
|||||||
Reference in New Issue
Block a user