fix(chat): 修复戳一戳等notice事件无法触发聊天流程的问题
该修复解决了机器人对“戳一戳”等 notice 事件没有响应的 bug。 问题根源在于 MessageManager 在处理 notice 消息时,仅将其添加到全局通知管理器后便直接返回,导致消息无法进入后续的聊天处理流程,即使相关配置已开启。 主要变更: 修改 Elysia/Bot/src/chat/message_manager/message_manager.py,在处理 notice 消息时,增加对 bot_config.toml 中 enable_notice_trigger_chat 配置的判断。只有在该配置为 false 时才中断流程,否则将消息继续送入聊天上下文。 修复了 _get_notice_ttl 函数中因 notice_type 可能为 None 而引发的潜在 TypeError。 将 Bot/src/config/official_configs.py 中 enable_notice_trigger_chat 的默认值从 False 修改为 True,以提供更合理的开箱即用体验。
This commit is contained in:
@@ -159,10 +159,17 @@ class MessageManager:
|
||||
try:
|
||||
# 检查是否为notice消息
|
||||
if self._is_notice_message(message):
|
||||
# Notice消息处理 - 不进入未读消息
|
||||
# Notice消息处理 - 添加到全局管理器
|
||||
logger.info(f"📢 检测到notice消息: message_id={message.message_id}, is_notify={message.is_notify}, notice_type={getattr(message, 'notice_type', None)}")
|
||||
await self._handle_notice_message(stream_id, message)
|
||||
return
|
||||
|
||||
# 根据配置决定是否继续处理(触发聊天流程)
|
||||
if not global_config.notice.enable_notice_trigger_chat:
|
||||
logger.info(f"根据配置,流 {stream_id} 的Notice消息将被忽略,不触发聊天流程。")
|
||||
return # 停止处理,不进入未读消息队列
|
||||
else:
|
||||
logger.info(f"根据配置,流 {stream_id} 的Notice消息将触发聊天流程。")
|
||||
# 继续执行,将消息添加到未读队列
|
||||
|
||||
# 普通消息处理
|
||||
chat_manager = get_chat_manager()
|
||||
@@ -748,6 +755,8 @@ class MessageManager:
|
||||
try:
|
||||
# 根据notice类型设置不同的TTL
|
||||
notice_type = self._get_notice_type(message)
|
||||
if notice_type is None:
|
||||
return 3600
|
||||
|
||||
ttl_mapping = {
|
||||
"poke": 1800, # 戳一戳30分钟
|
||||
|
||||
Reference in New Issue
Block a user