fix(dashboard): CONNECT log TypeError when bot identity is a dict

The bot reports identity as {id, username, tag}; the CONNECT log concatenated
that dict onto a string, raising TypeError and 500ing /api/bot/report (breaking
the bot's command/settings round-trip). Extract a string field (tag/username/id)
before formatting.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-08-26 23:54:54 +09:00
parent 1ac45214ce
commit ed5f328889

View File

@@ -256,7 +256,13 @@ def _make_handler(dash: "Dashboard"):
was_connected = dash.bot.state().get("connected")
dash.bot.report(data)
if not was_connected: # transition disconnected -> connected
who = data.get("botTag") or data.get("username") or data.get("identity") or ""
# identity is reported as {id, username, tag}; pull a string only
# (concatenating a dict here would TypeError and 500 the report).
ident = data.get("identity")
if isinstance(ident, dict):
who = ident.get("tag") or ident.get("username") or ident.get("id") or ""
else:
who = ident if isinstance(ident, str) else ""
monitor.log("info", f"디스코드 봇 연결됨{(' · ' + who) if who else ''}", cat="CONNECT")
# Hand the bot any queued commands + the current listen filters +
# behaviour settings in the same round trip so it does not have to