diff --git a/src/chat/message_receive/bot.py b/src/chat/message_receive/bot.py index b8418b6e3..bef80d5f8 100644 --- a/src/chat/message_receive/bot.py +++ b/src/chat/message_receive/bot.py @@ -349,8 +349,12 @@ class ChatBot: from src.plugin_system.apis.send_api import put_adapter_response seg_data = message.message_segment.data - request_id = seg_data.get("request_id") - response_data = seg_data.get("response") + if isinstance(seg_data, dict): + request_id = seg_data.get("request_id") + response_data = seg_data.get("response") + else: + request_id = None + response_data = None if request_id and response_data: logger.debug(f"收到适配器响应: request_id={request_id}") @@ -432,7 +436,6 @@ class ChatBot: # logger.debug(str(message_data)) message = MessageRecv(message_data) - message.is_mentioned, _ = is_mentioned_bot_in_message(message) group_info = message.message_info.group_info user_info = message.message_info.user_info if message.message_info.additional_config: @@ -454,6 +457,8 @@ class ChatBot: # 处理消息内容,生成纯文本 await message.process() + message.is_mentioned, _ = is_mentioned_bot_in_message(message) + # 在这里打印[所见]日志,确保在所有处理和过滤之前记录 chat_name = chat.group_info.group_name if chat.group_info else "私聊" logger.info( @@ -689,8 +694,17 @@ class ChatBot: # 先交给消息管理器处理,计算兴趣度等衍生数据 try: - await message_manager.add_message(message.chat_stream.stream_id, db_message) - logger.debug(f"消息已添加到消息管理器: {message.chat_stream.stream_id}") + # 在将消息添加到管理器之前进行最终的静默检查 + should_process_in_manager = True + if group_info and group_info.group_id in global_config.message_receive.mute_group_list: + if not message.is_mentioned: + logger.debug(f"群组 {group_info.group_id} 在静默列表中,且消息不是@或回复,跳过消息管理器处理") + should_process_in_manager = False + + if should_process_in_manager: + await message_manager.add_message(message.chat_stream.stream_id, db_message) + logger.debug(f"消息已添加到消息管理器: {message.chat_stream.stream_id}") + except Exception as e: logger.error(f"消息添加到消息管理器失败: {e}") diff --git a/src/config/official_configs.py b/src/config/official_configs.py index 8499071c0..4d3749b55 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -148,6 +148,9 @@ class MessageReceiveConfig(ValidatedConfigBase): ban_words: list[str] = Field(default_factory=lambda: [], description="禁用词列表") ban_msgs_regex: list[str] = Field(default_factory=lambda: [], description="禁用消息正则列表") + mute_group_list: list[str] = Field( + default_factory=list, description="静默群组列表,在这些群组中,只有在被@或回复时才会响应" + ) class NoticeConfig(ValidatedConfigBase): diff --git a/src/plugins/built_in/tts_voice_plugin/actions/tts_action.py b/src/plugins/built_in/tts_voice_plugin/actions/tts_action.py index 44de6d754..bd99e784b 100644 --- a/src/plugins/built_in/tts_voice_plugin/actions/tts_action.py +++ b/src/plugins/built_in/tts_voice_plugin/actions/tts_action.py @@ -45,8 +45,8 @@ class TTSVoiceAction(BaseAction): 3. LLM 判断当前场景适合发送语音 """ # 条件1: 随机激活 - if await self._random_activation(0.55): - logger.info(f"{self.log_prefix} 随机激活成功 (55%)") + if await self._random_activation(0.25): + logger.info(f"{self.log_prefix} 随机激活成功 (25%)") return True # 条件2: 关键词激活 diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index c66fa35c7..20844e4a5 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "7.3.4" +version = "7.3.5" #----以下是给开发人员阅读的,如果你只是部署了MoFox-Bot,不需要阅读---- #如果你想要修改配置文件,请递增version的值 @@ -148,6 +148,9 @@ ban_msgs_regex = [ #"https?://[^\\s]+", # 匹配https链接 #"\\d{4}-\\d{2}-\\d{2}", # 匹配日期 ] +# 静默群组列表,在这些群组中,只有在被@或回复时才会响应 +# 格式: ["group_id1", "group_id2"] +mute_group_list = [] [notice] # Notice消息配置 enable_notice_trigger_chat = false # 是否允许notice消息触发聊天流程(默认关闭,notice只会被记录但不会触发回复)