From c7f40d7a03740f1d4ed6a25a1ad23ecb531bc074 Mon Sep 17 00:00:00 2001 From: Plutor-05 Date: Fri, 9 May 2025 09:16:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=83=BD=E6=AD=A3=E7=A1=AE=E4=BC=A0=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/config.py | 24 ++++++++++++------------ src/plugins/PFC/PFC_idle/idle_chat.py | 10 +++++----- template/bot_config_template.toml | 8 ++++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/config/config.py b/src/config/config.py index da5b3c2e..1e18e58e 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -275,11 +275,11 @@ class BotConfig: enable_pfc_chatting: bool = False # 是否启用PFC聊天 enable_pfc_reply_checker: bool = True # 是否开启PFC回复检查 - # idle_conversation - enable_idle_conversation: bool = False # 是否启用 pfc 主动发言 + # idle_chat + enable_idle_chat: bool = False # 是否启用 pfc 主动发言 idle_check_interval: int = 10 # 检查间隔,10分钟检查一次 - min_idle_time: int = 7200 # 最短无活动时间,2小时 (7200秒) - max_idle_time: int = 18000 # 最长无活动时间,5小时 (18000秒) + min_cooldown: int = 7200 # 最短冷却时间,2小时 (7200秒) + max_cooldown: int = 18000 # 最长冷却时间,5小时 (18000秒) # 模型配置 llm_reasoning: dict[str, str] = field(default_factory=lambda: {}) @@ -671,17 +671,17 @@ class BotConfig: ) logger.info(f"PFC Reply Checker 状态: {'启用' if config.enable_pfc_reply_checker else '关闭'}") - def idle_conversation(parent: dict): - idle_conversation_config = parent["idle_conversation"] + def idle_chat(parent: dict): + idle_chat_config = parent["idle_chat"] 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.enable_idle_chat = idle_chat_config.get( + "enable_idle_chat", config.enable_idle_chat ) - config.idle_check_interval = idle_conversation_config.get( + config.idle_check_interval = idle_chat_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) + config.min_cooldown = idle_chat_config.get("min_cooldown", config.min_cooldown) + config.max_cooldown = idle_chat_config.get("max_cooldown", config.max_cooldown) # 版本表达式:>=1.0.0,<2.0.0 # 允许字段:func: method, support: str, notice: str, necessary: bool @@ -716,7 +716,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}, + "idle_chat": {"func": idle_chat, "support": ">=1.6.2", "necessary": False}, } # 原地修改,将 字符串版本表达式 转换成 版本对象 diff --git a/src/plugins/PFC/PFC_idle/idle_chat.py b/src/plugins/PFC/PFC_idle/idle_chat.py index 3e5350b1..6892bf69 100644 --- a/src/plugins/PFC/PFC_idle/idle_chat.py +++ b/src/plugins/PFC/PFC_idle/idle_chat.py @@ -144,8 +144,8 @@ class IdleChat: self._task: Optional[asyncio.Task] = None # 配置参数 - 从global_config加载 - self.min_cooldown = global_config.min_idle_time # 最短冷却时间(默认2小时) - self.max_cooldown = global_config.max_idle_time # 最长冷却时间(默认5小时) + self.min_cooldown = global_config.min_cooldown # 最短冷却时间(默认2小时) + self.max_cooldown = global_config.max_cooldown # 最长冷却时间(默认5小时) self.check_interval = global_config.idle_check_interval * 60 # 检查间隔(默认10分钟,转换为秒) self.active_hours_start = 7 # 活动开始时间 self.active_hours_end = 23 # 活动结束时间 @@ -157,8 +157,8 @@ class IdleChat: def start(self) -> None: """启动主动聊天检测""" # 检查是否启用了主动聊天功能 - if not global_config.enable_idle_conversation: - logger.info(f"[私聊][{self.private_name}]主动聊天功能已禁用(配置ENABLE_IDLE_CONVERSATION=False)") + if not global_config.enable_idle_chat: + logger.info(f"[私聊][{self.private_name}]主动聊天功能已禁用(配置ENABLE_IDLE_CHAT=False)") return if self._running: @@ -350,7 +350,7 @@ class IdleChat: try: while self._running: # 检查是否启用了主动聊天功能 - if not global_config.enable_idle_conversation: + if not global_config.enable_idle_chat: # 如果禁用了功能,等待一段时间后再次检查配置 await asyncio.sleep(60) # 每分钟检查一次配置变更 continue diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 55b22cad..41015771 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -190,11 +190,11 @@ talk_allowed_private = [] # 可以回复消息的QQ号 pfc_chatting = false # 是否启用PFC聊天,该功能仅作用于私聊,与回复模式独立 enable_pfc_reply_checker = true # 是否启用 PFC 的回复检查器 -[idle_conversation] -enable_idle_conversation = false # 是否启用 pfc 主动发言 +[idle_chat] +enable_idle_chat = false # 是否启用 pfc 主动发言 idle_check_interval = 10 # 检查间隔,10分钟检查一次 -min_idle_time = 7200 # 最短无活动时间,2小时 (7200秒) -max_idle_time = 18000 # 最长无活动时间,5小时 (18000秒) +min_cooldown = 7200 # 最短冷却时间,2小时 (7200秒) +max_cooldown = 18000 # 最长冷却时间,5小时 (18000秒) #下面的模型若使用硅基流动则不需要更改,使用ds官方则改成.env自定义的宏,使用自定义模型则选择定位相似的模型自己填写 #推理模型 From f9f3d6e89fa2392d394a4275772ff485d6a75ce2 Mon Sep 17 00:00:00 2001 From: Plutor-05 Date: Fri, 9 May 2025 13:23:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E4=BC=A0=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/PFC/PFC_idle/idle_chat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/PFC/PFC_idle/idle_chat.py b/src/plugins/PFC/PFC_idle/idle_chat.py index 6892bf69..4bffe66a 100644 --- a/src/plugins/PFC/PFC_idle/idle_chat.py +++ b/src/plugins/PFC/PFC_idle/idle_chat.py @@ -492,12 +492,12 @@ class IdleChat: else: schedule_prompt = "" - # 构建提示词 + # 构建提示词,暂存废弃部分这是你的日程{schedule_prompt} current_time = datetime.now().strftime("%H:%M") prompt = f"""你是{global_config.BOT_NICKNAME}。 你正在与用户{self.private_name}进行QQ私聊,你们的关系是{relationship_description} 现在时间{current_time} - 这是你的日程{schedule_prompt} + 你想要主动发起对话。 请基于以下之前的对话历史,生成一条自然、友好、符合关系程度的主动对话消息。 这条消息应能够引起用户的兴趣,重新开始对话。