Skip to content

Your lightweight open-source personal agent.

fix: sanitize Matrix user_id for Windows-safe store file names

Jiajun Xie95715f521179
diff --git a/nanobot/channels/matrix.py b/nanobot/channels/matrix.py
index 85a167a3a..8ce08ae61 100644
--- a/nanobot/channels/matrix.py
+++ b/nanobot/channels/matrix.py
@@ -262,10 +262,18 @@ class MatrixChannel(BaseChannel):
self.store_path.mkdir(parents=True, exist_ok=True)
self.session_path = self.store_path / "session.json"
+ # Replace ':' with '_' to produce a Windows-safe filename
+ safe_store_name = self.config.user_id.replace(":", "_") + f"_{self.config.device_id}.db"
+
self.client = AsyncClient(
- homeserver=self.config.homeserver, user=self.config.user_id,
+ homeserver=self.config.homeserver,
+ user=self.config.user_id,
store_path=self.store_path,
- config=AsyncClientConfig(store_sync_tokens=True, encryption_enabled=self.config.e2ee_enabled),
+ config=AsyncClientConfig(
+ store_sync_tokens=True,
+ encryption_enabled=self.config.e2ee_enabled,
+ store_name=safe_store_name,
+ ),
)
self._register_event_callbacks()