fix: align sender paths with plan, remove QQ-as-universal fallback
- Remove get_bot_account("qq") fallback from all 4 sender paths
(plan L108/L208/L449: unknown platform = no account, never substitute QQ)
- Sender paths now error immediately if platform bot account is not configured
- Add detailed comments on filter_bot legacy fallback explaining why
global user_id match is needed (plan contingency L528 insufficient for
platform-tagged legacy rows like telegram+qq_account)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,10 +44,8 @@ class DirectMessageSender:
|
||||
# 获取麦麦的信息
|
||||
bot_user_id = get_bot_account(chat_stream.platform)
|
||||
if not bot_user_id:
|
||||
bot_user_id = get_bot_account("qq")
|
||||
if not bot_user_id:
|
||||
logger.error(f"[私聊][{self.private_name}]平台 {chat_stream.platform} 无可用机器人账号,无法发送消息")
|
||||
raise RuntimeError("机器人账号未配置")
|
||||
logger.error(f"[私聊][{self.private_name}]平台 {chat_stream.platform} 未配置机器人账号,无法发送消息")
|
||||
raise RuntimeError(f"平台 {chat_stream.platform} 未配置机器人账号")
|
||||
bot_user_info = UserInfo(
|
||||
user_id=bot_user_id,
|
||||
user_nickname=global_config.bot.nickname,
|
||||
|
||||
@@ -1117,10 +1117,8 @@ class DefaultReplyer:
|
||||
"""构建单个发送消息"""
|
||||
bot_user_id = get_bot_account(self.chat_stream.platform)
|
||||
if not bot_user_id:
|
||||
bot_user_id = get_bot_account("qq")
|
||||
if not bot_user_id:
|
||||
logger.error(f"平台 {self.chat_stream.platform} 无可用机器人账号,无法构建发送消息")
|
||||
raise RuntimeError("机器人账号未配置")
|
||||
logger.error(f"平台 {self.chat_stream.platform} 未配置机器人账号,无法构建发送消息")
|
||||
raise RuntimeError(f"平台 {self.chat_stream.platform} 未配置机器人账号")
|
||||
|
||||
maim_message = MessageBase(
|
||||
message_info=BaseMessageInfo(
|
||||
|
||||
@@ -957,10 +957,8 @@ class PrivateReplyer:
|
||||
"""构建单个发送消息"""
|
||||
bot_user_id = get_bot_account(self.chat_stream.platform)
|
||||
if not bot_user_id:
|
||||
bot_user_id = get_bot_account("qq")
|
||||
if not bot_user_id:
|
||||
logger.error(f"平台 {self.chat_stream.platform} 无可用机器人账号,无法构建发送消息")
|
||||
raise RuntimeError("机器人账号未配置")
|
||||
logger.error(f"平台 {self.chat_stream.platform} 未配置机器人账号,无法构建发送消息")
|
||||
raise RuntimeError(f"平台 {self.chat_stream.platform} 未配置机器人账号")
|
||||
|
||||
maim_message = MessageBase(
|
||||
message_info=BaseMessageInfo(
|
||||
|
||||
@@ -176,7 +176,10 @@ def find_messages(
|
||||
)
|
||||
)
|
||||
|
||||
# 兼容旧数据:历史机器人消息在所有平台上都使用 QQ 账号进行存储。
|
||||
# 兼容旧数据:历史机器人消息在所有平台上都使用 QQ 账号作为 user_id 存储,
|
||||
# 例如旧 Telegram bot 消息的 (platform="telegram", user_id=qq_account)。
|
||||
# plan 建议的 ("", qq_account) pair 只能覆盖空 platform 行,无法覆盖这种情况。
|
||||
# 因此这里使用全局 user_id 匹配作为临时方案,待 DB 迁移后应移除此兜底。
|
||||
if qq_fallback := get_bot_account("qq"):
|
||||
exclusion_conditions.append(Messages.user_id == qq_fallback)
|
||||
|
||||
|
||||
@@ -85,9 +85,7 @@ async def _send_to_target(
|
||||
additional_config["selected_expressions"] = selected_expressions
|
||||
bot_user_id = get_bot_account(target_stream.platform)
|
||||
if not bot_user_id:
|
||||
bot_user_id = get_bot_account("qq")
|
||||
if not bot_user_id:
|
||||
logger.error(f"[SendService] 平台 {target_stream.platform} 无可用机器人账号,无法发送消息")
|
||||
logger.error(f"[SendService] 平台 {target_stream.platform} 未配置机器人账号,无法发送消息")
|
||||
return False
|
||||
|
||||
maim_message = MessageBase(
|
||||
|
||||
Reference in New Issue
Block a user