feat(bot): add initial sync before continuous sync

Added an initial sync with a timeout of 30000ms before starting continuous synchronization to ensure the bot is ready with the latest state from the server. This change aims to prevent any missed messages that might occur during the startup phase.
This commit is contained in:
Kumi 2024-08-09 11:53:31 +02:00
parent a9ca33c77b
commit 7bfcda09b8
Signed by: kumi
GPG key ID: ECBCC9082395383F

1
bot.py
View file

@ -61,6 +61,7 @@ class RoombaBot:
async def start(self): async def start(self):
"""Start the bot.""" """Start the bot."""
await self.client.sync(timeout=30000)
self.client.add_event_callback(self.message_callback, nio.RoomMessageText) self.client.add_event_callback(self.message_callback, nio.RoomMessageText)
await self.client.sync_forever(timeout=30000) await self.client.sync_forever(timeout=30000)