From 46359a893320c1d6fde6192e9edfea4598670da7 Mon Sep 17 00:00:00 2001 From: ikun-11451 <334495606@qq.com> Date: Sun, 30 Nov 2025 21:51:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E8=AF=A5=E6=98=AF=E6=8A=8A=E7=A7=81?= =?UTF-8?q?=E8=81=8A=E5=BF=85=E5=9B=9E=E5=8A=A0=E5=9B=9E=E6=9D=A5=E4=BA=86?= =?UTF-8?q?=E5=96=B5=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/official_configs.py | 1 + .../affinity_flow_chatter/planner/planner.py | 21 +++++++++++++++---- template/bot_config_template.toml | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/config/official_configs.py b/src/config/official_configs.py index c0b8a5e0c..18f5f8e52 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -134,6 +134,7 @@ class ChatConfig(ValidatedConfigBase): thinking_timeout: int = Field(default=40, description="思考超时时间") mentioned_bot_inevitable_reply: bool = Field(default=False, description="提到机器人的必然回复") at_bot_inevitable_reply: bool = Field(default=False, description="@机器人的必然回复") + private_chat_inevitable_reply: bool = Field(default=False, description="私聊必然回复") allow_reply_self: bool = Field(default=False, description="是否允许回复自己说的话") timestamp_display_mode: Literal["normal", "normal_no_YMD", "relative"] = Field( default="normal_no_YMD", description="时间戳显示模式" diff --git a/src/plugins/built_in/affinity_flow_chatter/planner/planner.py b/src/plugins/built_in/affinity_flow_chatter/planner/planner.py index c12bf71ab..8bc750165 100644 --- a/src/plugins/built_in/affinity_flow_chatter/planner/planner.py +++ b/src/plugins/built_in/affinity_flow_chatter/planner/planner.py @@ -13,7 +13,7 @@ from src.chat.message_receive.storage import MessageStorage from src.common.logger import get_logger from src.config.config import global_config from src.mood.mood_manager import mood_manager -from src.plugin_system.base.component_types import ChatMode +from src.plugin_system.base.component_types import ChatMode, ChatType from src.plugins.built_in.affinity_flow_chatter.planner.plan_executor import ChatterPlanExecutor from src.plugins.built_in.affinity_flow_chatter.planner.plan_filter import ChatterPlanFilter from src.plugins.built_in.affinity_flow_chatter.planner.plan_generator import ChatterPlanGenerator @@ -201,6 +201,10 @@ class ChatterActionPlanner: reply_not_available = True aggregate_should_act = False + # 检查私聊必回配置 + is_private_chat = context and context.chat_type == ChatType.PRIVATE + force_reply = is_private_chat and global_config.chat.private_chat_inevitable_reply + if unread_messages: # 直接使用消息中已计算的标志,无需重复计算兴趣值 for message in unread_messages: @@ -219,9 +223,11 @@ class ChatterActionPlanner: f"should_reply={message_should_reply}, should_act={message_should_act}" ) - if message_should_reply: + if message_should_reply or force_reply: aggregate_should_act = True reply_not_available = False + if force_reply: + logger.info(f"Focus模式 - 私聊必回已启用,强制回复消息 {message.message_id}") break if message_should_act: @@ -394,12 +400,19 @@ class ChatterActionPlanner: should_reply = False target_message = None + # 检查私聊必回配置 + is_private_chat = context and context.chat_type == ChatType.PRIVATE + force_reply = is_private_chat and global_config.chat.private_chat_inevitable_reply + for message in unread_messages: message_should_reply = getattr(message, "should_reply", False) - if message_should_reply: + if message_should_reply or force_reply: should_reply = True target_message = message - logger.info(f"Normal模式 - 消息 {message.message_id} 达到reply阈值,准备回复") + if force_reply: + logger.info(f"Normal模式 - 私聊必回已启用,强制回复消息 {message.message_id}") + else: + logger.info(f"Normal模式 - 消息 {message.message_id} 达到reply阈值,准备回复") break if should_reply and target_message: diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 3c208dc76..ad757383a 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "7.9.1" +version = "7.9.2" #----以下是给开发人员阅读的,如果你只是部署了MoFox-Bot,不需要阅读---- #如果你想要修改配置文件,请递增version的值 @@ -171,6 +171,7 @@ learning_strength = 0.5 [chat] #MoFox-Bot的聊天通用设置 allow_reply_self = false # 是否允许回复自己说的话 +private_chat_inevitable_reply = false # 私聊必然回复 max_context_size = 25 # 上下文长度 thinking_timeout = 40 # MoFox-Bot一次回复最长思考规划时间,超过这个时间的思考会放弃(往往是api反应太慢)