From e294253b1ae7f6f5b93554a53160b9e6355dcdd8 Mon Sep 17 00:00:00 2001 From: Bakadax Date: Tue, 6 May 2025 08:59:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20config.py=20=E4=B8=BB?= =?UTF-8?q?=E5=8A=A8=E5=8F=91=E8=A8=80=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/config.py | 15 +++++++++++++++ src/plugins/PFC/idle_conversation_starter.py | 2 +- template/bot_config_template.toml | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/config/config.py b/src/config/config.py index 28d947ef..4ca8aa30 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -274,6 +274,12 @@ class BotConfig: talk_allowed_private = set() enable_pfc_chatting: bool = False # 是否启用PFC聊天 + # idle_conversation + enable_idle_conversation: bool = True # 是否启用 pfc 主动发言(未完善) + idle_check_interval: int = 10 # 检查间隔,10分钟检查一次 + min_idle_time: int = 7200 # 最短无活动时间,2小时 (7200秒) + max_idle_time: int = 18000 # 最长无活动时间,5小时 (18000秒) + # 模型配置 llm_reasoning: dict[str, str] = field(default_factory=lambda: {}) # llm_reasoning_minor: dict[str, str] = field(default_factory=lambda: {}) @@ -659,6 +665,14 @@ class BotConfig: if config.INNER_VERSION in SpecifierSet(">=1.1.0"): config.enable_pfc_chatting = experimental_config.get("pfc_chatting", config.enable_pfc_chatting) + def idle_conversation(parent: dict): + idle_conversation_config = parent["idle_conversation"] + if config.INNER_VERSION in SpecifierSet(">=1.6.2"): + config.enable_idle_conversation = idle_conversation_config.get("enable_idle_conversation", config.enable_idle_conversation) + config.idle_check_interval = idle_conversation_config.get("idle_check_interval", config.idle_check_interval) + config.min_idle_time = idle_conversation_config.get("min_idle_time", config.min_idle_time) + config.max_idle_time = idle_conversation_config.get("max_idle_time", config.max_idle_time) + # 版本表达式:>=1.0.0,<2.0.0 # 允许字段:func: method, support: str, notice: str, necessary: bool # 如果使用 notice 字段,在该组配置加载时,会展示该字段对用户的警示 @@ -692,6 +706,7 @@ class BotConfig: "chat": {"func": chat, "support": ">=1.6.0", "necessary": False}, "normal_chat": {"func": normal_chat, "support": ">=1.6.0", "necessary": False}, "focus_chat": {"func": focus_chat, "support": ">=1.6.0", "necessary": False}, + "idle_conversation": {"func": idle_conversation, "support": ">=1.6.2", "necessary": False}, } # 原地修改,将 字符串版本表达式 转换成 版本对象 diff --git a/src/plugins/PFC/idle_conversation_starter.py b/src/plugins/PFC/idle_conversation_starter.py index d79319c6..eb55c3cb 100644 --- a/src/plugins/PFC/idle_conversation_starter.py +++ b/src/plugins/PFC/idle_conversation_starter.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: from ..chat.message import Message from .conversation import Conversation -logger = get_module_logger("pfc") +logger = get_module_logger("idle_conversation") class IdleConversationStarter: """长时间无对话主动发起对话的组件 diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 646f72cd..5f8e3760 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "1.6.1" +version = "1.6.2" #----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读---- #如果你想要修改配置文件,请在修改后将version的值进行变更