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反应太慢)