feat(matrix): land QA follow-ups and refresh docs
- harden Matrix onboarding/chat lifecycle after manual QA - refresh README and Matrix docs to match current behavior - add local ignores for runtime artifacts and include current planning/report docs Closes #7 Closes #9 Closes #14
This commit is contained in:
parent
7fce4c9b3e
commit
6ced154124
35 changed files with 8380 additions and 67 deletions
|
|
@ -14,6 +14,7 @@ from nio import (
|
|||
RoomMemberEvent,
|
||||
RoomMessageText,
|
||||
)
|
||||
from nio.responses import SyncResponse
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from adapter.matrix.converter import from_room_event
|
||||
|
|
@ -115,12 +116,20 @@ class MatrixBot:
|
|||
self.runtime.platform,
|
||||
self.runtime.store,
|
||||
self.runtime.auth_mgr,
|
||||
self.runtime.chat_mgr,
|
||||
)
|
||||
|
||||
async def _send_all(self, room_id: str, outgoing: list[OutgoingEvent]) -> None:
|
||||
for event in outgoing:
|
||||
await send_outgoing(self.client, room_id, event, store=self.runtime.store)
|
||||
|
||||
|
||||
async def prepare_live_sync(client: AsyncClient) -> str | None:
|
||||
response = await client.sync(timeout=0, full_state=True)
|
||||
if isinstance(response, SyncResponse):
|
||||
return response.next_batch
|
||||
return None
|
||||
|
||||
async def send_outgoing(
|
||||
client: AsyncClient,
|
||||
room_id: str,
|
||||
|
|
@ -197,6 +206,8 @@ async def main() -> None:
|
|||
elif password:
|
||||
await client.login(password=password, device_name="surfaces-bot")
|
||||
|
||||
since_token = await prepare_live_sync(client)
|
||||
|
||||
bot = MatrixBot(client, runtime)
|
||||
client.add_event_callback(bot.on_room_message, RoomMessageText)
|
||||
client.add_event_callback(bot.on_member, (InviteMemberEvent, RoomMemberEvent))
|
||||
|
|
@ -209,7 +220,7 @@ async def main() -> None:
|
|||
request_timeout=client_config.request_timeout,
|
||||
)
|
||||
try:
|
||||
await client.sync_forever(timeout=30000)
|
||||
await client.sync_forever(timeout=30000, since=since_token)
|
||||
finally:
|
||||
await client.close()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue