From 57f5a19d0c86d0c97fb5364f19c04c5e6cd5497c Mon Sep 17 00:00:00 2001 From: YuF-bot Date: Sat, 28 Feb 2026 11:10:15 +0800 Subject: [PATCH] fix(message): fallback Telegram username to string userid when absent --- app/chain/message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/chain/message.py b/app/chain/message.py index 847b2732..d327a709 100644 --- a/app/chain/message.py +++ b/app/chain/message.py @@ -112,8 +112,8 @@ class MessageChain(ChainBase): channel = info.channel # 用户ID userid = info.userid - # 用户名 - username = info.username or userid + # 用户名(当渠道未提供公开用户名时,回退为 userid 的字符串,避免后续类型校验异常) + username = str(info.username) if info.username not in (None, "") else str(userid) if userid is None or userid == '': logger.debug(f'未识别到用户ID:{body}{form}{args}') return