Appearance
Discord:bot 在 free_response_channels 中静默忽略引用回复
问题
在 discord.free_response_channels 列表中的频道里,用户对 bot 发送的消息(例如 cron 任务输出)进行 右键 → Reply(引用回复) 时,bot 不响应,也不记录任何日志。
复现步骤:
- Bot 向
free_response_channel发送一条消息(如 cron 定时输出) - 用户右键 → "Reply" 该消息,不 @提及 bot
- 用户发送消息
- Bot 无响应
根本原因:Discord gateway 的消息处理逻辑只检查 message.mentions(消息中的 @提及),不检查 message.reference(Discord 的引用回复机制)。引用回复不产生 @提及,因此被过滤掉了。
解决方案
在 gateway/platforms/discord.py 的消息处理逻辑中,补充对 message.reference 的检查:
python
# 当前(概念示意)
is_relevant = bot_id in message.mentions
# 修改后
is_relevant = (
bot_id in message.mentions
or (message.reference and message.reference.resolved and
message.reference.resolved.author.id == bot_id)
)即:如果消息是对 bot 发出的消息的引用回复,也应该触发响应。
临时绕过:在引用回复时主动 @提及 bot,即可触发正常响应。
Issue:#9399