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:
@@ -256,7 +256,13 @@ def _make_handler(dash: "Dashboard"):
|
|||||||
was_connected = dash.bot.state().get("connected")
|
was_connected = dash.bot.state().get("connected")
|
||||||
dash.bot.report(data)
|
dash.bot.report(data)
|
||||||
if not was_connected: # transition disconnected -> connected
|
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")
|
monitor.log("info", f"디스코드 봇 연결됨{(' · ' + who) if who else ''}", cat="CONNECT")
|
||||||
# Hand the bot any queued commands + the current listen filters +
|
# Hand the bot any queued commands + the current listen filters +
|
||||||
# behaviour settings in the same round trip so it does not have to
|
# behaviour settings in the same round trip so it does not have to
|
||||||
|
|||||||
Reference in New Issue
Block a user