Check set_presence return value for errors
matrix-nio's set_presence() doesn't raise on failure — it returns a PresenceSetError object. The code was ignoring the return value, so the bot would silently fail to go online even with valid credentials. https://claude.ai/code/session_019ANRdyL2jfi7ysWhqN4PfD
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from nio import AsyncClient, RoomSendResponse
|
from nio import AsyncClient, PresenceSetError, RoomSendResponse
|
||||||
|
|
||||||
from app.config import config
|
from app.config import config
|
||||||
|
|
||||||
@@ -48,7 +48,9 @@ async def close_client() -> None:
|
|||||||
|
|
||||||
async def _set_presence(state: str) -> None:
|
async def _set_presence(state: str) -> None:
|
||||||
client = await get_client()
|
client = await get_client()
|
||||||
await client.set_presence(state)
|
resp = await client.set_presence(state)
|
||||||
|
if isinstance(resp, PresenceSetError):
|
||||||
|
raise RuntimeError(f"Presence update to '{state}' failed: {resp.message}")
|
||||||
|
|
||||||
|
|
||||||
async def _presence_loop() -> None:
|
async def _presence_loop() -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user