mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(pairing): handle null user_name in pairing list display
When user_name is stored as None (e.g. Telegram users without a
display name), dict.get('user_name', '') returns None because the
key exists — the default is only used for missing keys. This causes
a TypeError when the format specifier :<20 is applied to None.
Use `or ''` to coerce None to an empty string.
Fixes #7392
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
48923e5a3d
commit
d7452af257
1 changed files with 3 additions and 3 deletions
|
|
@ -44,7 +44,7 @@ def _cmd_list(store):
|
||||||
for p in pending:
|
for p in pending:
|
||||||
print(
|
print(
|
||||||
f" {p['platform']:<12} {p['code']:<10} {p['user_id']:<20} "
|
f" {p['platform']:<12} {p['code']:<10} {p['user_id']:<20} "
|
||||||
f"{p.get('user_name', ''):<20} {p['age_minutes']}m ago"
|
f"{(p.get('user_name') or ''):<20} {p['age_minutes']}m ago"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
print("\n No pending pairing requests.")
|
print("\n No pending pairing requests.")
|
||||||
|
|
@ -54,7 +54,7 @@ def _cmd_list(store):
|
||||||
print(f" {'Platform':<12} {'User ID':<20} {'Name':<20}")
|
print(f" {'Platform':<12} {'User ID':<20} {'Name':<20}")
|
||||||
print(f" {'--------':<12} {'-------':<20} {'----':<20}")
|
print(f" {'--------':<12} {'-------':<20} {'----':<20}")
|
||||||
for a in approved:
|
for a in approved:
|
||||||
print(f" {a['platform']:<12} {a['user_id']:<20} {a.get('user_name', ''):<20}")
|
print(f" {a['platform']:<12} {a['user_id']:<20} {(a.get('user_name') or ''):<20}")
|
||||||
else:
|
else:
|
||||||
print("\n No approved users.")
|
print("\n No approved users.")
|
||||||
|
|
||||||
|
|
@ -69,7 +69,7 @@ def _cmd_approve(store, platform: str, code: str):
|
||||||
result = store.approve_code(platform, code)
|
result = store.approve_code(platform, code)
|
||||||
if result:
|
if result:
|
||||||
uid = result["user_id"]
|
uid = result["user_id"]
|
||||||
name = result.get("user_name", "")
|
name = result.get("user_name") or ""
|
||||||
display = f"{name} ({uid})" if name else uid
|
display = f"{name} ({uid})" if name else uid
|
||||||
print(f"\n Approved! User {display} on {platform} can now use the bot~")
|
print(f"\n Approved! User {display} on {platform} can now use the bot~")
|
||||||
print(" They'll be recognized automatically on their next message.\n")
|
print(" They'll be recognized automatically on their next message.\n")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue