fix: use loguru native formatting to prevent KeyError on messages containing curly braces

Closes #857
This commit is contained in:
Nikolas de Hor
2026-02-19 17:19:36 -03:00
parent d22929305f
commit 53b83a38e2
18 changed files with 80 additions and 80 deletions

View File

@@ -51,7 +51,7 @@ class DiscordChannel(BaseChannel):
except asyncio.CancelledError:
break
except Exception as e:
logger.warning(f"Discord gateway error: {e}")
logger.warning("Discord gateway error: {}", e)
if self._running:
logger.info("Reconnecting to Discord gateway in 5 seconds...")
await asyncio.sleep(5)
@@ -101,7 +101,7 @@ class DiscordChannel(BaseChannel):
return
except Exception as e:
if attempt == 2:
logger.error(f"Error sending Discord message: {e}")
logger.error("Error sending Discord message: {}", e)
else:
await asyncio.sleep(1)
finally:
@@ -116,7 +116,7 @@ class DiscordChannel(BaseChannel):
try:
data = json.loads(raw)
except json.JSONDecodeError:
logger.warning(f"Invalid JSON from Discord gateway: {raw[:100]}")
logger.warning("Invalid JSON from Discord gateway: {}", raw[:100])
continue
op = data.get("op")
@@ -175,7 +175,7 @@ class DiscordChannel(BaseChannel):
try:
await self._ws.send(json.dumps(payload))
except Exception as e:
logger.warning(f"Discord heartbeat failed: {e}")
logger.warning("Discord heartbeat failed: {}", e)
break
await asyncio.sleep(interval_s)
@@ -219,7 +219,7 @@ class DiscordChannel(BaseChannel):
media_paths.append(str(file_path))
content_parts.append(f"[attachment: {file_path}]")
except Exception as e:
logger.warning(f"Failed to download Discord attachment: {e}")
logger.warning("Failed to download Discord attachment: {}", e)
content_parts.append(f"[attachment: {filename} - download failed]")
reply_to = (payload.get("referenced_message") or {}).get("id")