Skip to content

Your lightweight open-source personal agent.

fix(matrix): guard store load without device id and allow invites by default

Alexander Mingesc926569033bc
diff --git a/nanobot/channels/matrix.py b/nanobot/channels/matrix.py
index f3b84689b..340ec2a9a 100644
--- a/nanobot/channels/matrix.py
+++ b/nanobot/channels/matrix.py
@@ -43,7 +43,8 @@ class MatrixChannel(BaseChannel):
self.client.add_event_callback(self._on_message, RoomMessageText)
self.client.add_event_callback(self._on_room_invite, InviteEvent)
- self.client.load_store()
+ if self.config.device_id:
+ self.client.load_store()
self._sync_task = asyncio.create_task(self._sync_loop())
@@ -74,9 +75,12 @@ class MatrixChannel(BaseChannel):
except Exception:
await asyncio.sleep(2)
- async def _on_room_invite(self, room: MatrixRoom, event: RoomMessageText) -> None:
- if event.sender in self.config.allow_from:
- await self.client.join(room.room_id)
+ async def _on_room_invite(self, room: MatrixRoom, event: InviteEvent) -> None:
+ allow_from = self.config.allow_from or []
+ if allow_from and event.sender not in allow_from:
+ return
+
+ await self.client.join(room.room_id)
async def _on_message(self, room: MatrixRoom, event: RoomMessageText) -> None:
# Ignore self messages