From aea3bffd996121d4462f1906ad9d5f2c9d0f5a3c Mon Sep 17 00:00:00 2001 From: Pliosauroidea Date: Tue, 11 Mar 2025 20:55:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A7=81=E8=81=8A=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=BC=80=E5=85=B3,=E6=9B=B4=E6=96=B0config,=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/chat/bot.py | 7 +------ src/plugins/chat/config.py | 5 ++++- template/bot_config_template.toml | 3 ++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/plugins/chat/bot.py b/src/plugins/chat/bot.py index 985c264c5..d9f410a74 100644 --- a/src/plugins/chat/bot.py +++ b/src/plugins/chat/bot.py @@ -31,7 +31,6 @@ from .willing_manager import willing_manager # 导入意愿管理器 from .message_base import UserInfo, GroupInfo, Seg - class ChatBot: def __init__(self): self.storage = MessageStorage() @@ -59,7 +58,7 @@ class ChatBot: # 处理私聊消息的逻辑 if isinstance(event, PrivateMessageEvent): - if not 0 in global_config.talk_allowed_groups: + if not global_config.enable_friend_chat: # 私聊过滤 return else: user_info = UserInfo( @@ -182,7 +181,6 @@ class ChatBot: ) current_willing = willing_manager.get_willing(chat_stream=chat) - logger.info( f"[{current_time}][{chat.group_info.group_name if chat.group_info.group_id else '私聊'}]{chat.user_info.user_nickname}:" f"{message.processed_plain_text}[回复意愿:{current_willing:.2f}][概率:{reply_probability * 100:.1f}%]" @@ -190,7 +188,6 @@ class ChatBot: response = None - if random() < reply_probability: bot_user_info = UserInfo( user_id=global_config.BOT_QQ, @@ -206,14 +203,12 @@ class ChatBot: reply=message, ) - message_manager.add_message(thinking_message) willing_manager.change_reply_willing_sent(chat) response, raw_content = await self.gpt.generate_response(message) - response, raw_content = await self.gpt.generate_response(message) # print(f"response: {response}") diff --git a/src/plugins/chat/config.py b/src/plugins/chat/config.py index 596d120f9..a53237e6a 100644 --- a/src/plugins/chat/config.py +++ b/src/plugins/chat/config.py @@ -69,6 +69,7 @@ class BotConfig: enable_advance_output: bool = False # 是否启用高级输出 enable_kuuki_read: bool = True # 是否启用读空气功能 enable_debug_output: bool = False # 是否启用调试输出 + enable_friend_chat: bool = False # 是否启用好友聊天 mood_update_interval: float = 1.0 # 情绪更新间隔 单位秒 mood_decay_rate: float = 0.95 # 情绪衰减率 @@ -327,7 +328,9 @@ class BotConfig: others_config = parent["others"] config.enable_advance_output = others_config.get("enable_advance_output", config.enable_advance_output) config.enable_kuuki_read = others_config.get("enable_kuuki_read", config.enable_kuuki_read) - config.enable_debug_output = others_config.get("enable_debug_output", config.enable_debug_output) + if config.INNER_VERSION in SpecifierSet(">=0.0.7"): + config.enable_debug_output = others_config.get("enable_debug_output", config.enable_debug_output) + config.enable_friend_chat = others_config.get("enable_friend_chat", config.enable_friend_chat) # 版本表达式:>=1.0.0,<2.0.0 # 允许字段:func: method, support: str, notice: str, necessary: bool diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index bea6ab7b7..eb0323cec 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "0.0.6" +version = "0.0.7" #如果你想要修改配置文件,请在修改后将version的值进行变更 #如果新增项目,请在BotConfig类下新增相应的变量 @@ -101,6 +101,7 @@ word_replace_rate=0.006 # 整词替换概率 enable_advance_output = true # 是否启用高级输出 enable_kuuki_read = true # 是否启用读空气功能 enable_debug_output = false # 是否启用调试输出 +enable_friend_chat = false # 是否启用好友聊天 [groups] talk_allowed = [