From caa8c491cf7c5719f64d167a4199027ff02f8a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=91=BE=E6=98=9FMcc?= <3422982454@qq.com> Date: Tue, 4 Mar 2025 20:40:52 +0800 Subject: [PATCH 1/2] Add files via upload --- src/plugins/chat/bot.py | 2 +- src/plugins/chat/willing_manager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/chat/bot.py b/src/plugins/chat/bot.py index d119b4ab9..65c721be2 100644 --- a/src/plugins/chat/bot.py +++ b/src/plugins/chat/bot.py @@ -140,7 +140,7 @@ class ChatBot: current_willing = willing_manager.get_willing(event.group_id) - print(f"\033[1;32m[{current_time}][{message.group_name}]{message.user_nickname}:\033[0m {message.processed_plain_text}\033[1;36m[回复意愿:{current_willing:.2f}][概率:{reply_probability:.1f}]\033[0m") + print(f"\033[1;32m[{current_time}][{message.group_name}]{message.user_nickname}:\033[0m {message.processed_plain_text}\033[1;36m[回复意愿:{current_willing:.2f}][概率:{reply_probability * 100:.1f}%]\033[0m") response = "" # 创建思考消息 if random() < reply_probability: diff --git a/src/plugins/chat/willing_manager.py b/src/plugins/chat/willing_manager.py index e35743577..86858e93d 100644 --- a/src/plugins/chat/willing_manager.py +++ b/src/plugins/chat/willing_manager.py @@ -50,7 +50,7 @@ class WillingManager: self.group_reply_willing[group_id] = min(current_willing, 3.0) - reply_probability = (current_willing - 0.5) * 2 + reply_probability = max((current_willing - 0.5) * 2, 0) if group_id not in config.talk_allowed_groups: current_willing = 0 reply_probability = 0 From 20a408ee7a871bf4586fc1dfeaf2abfd7ba6e559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=91=BE=E6=98=9FMcc?= <3422982454@qq.com> Date: Tue, 4 Mar 2025 21:53:33 +0800 Subject: [PATCH 2/2] Update willing_manager.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 防止概率大于100% --- src/plugins/chat/willing_manager.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/chat/willing_manager.py b/src/plugins/chat/willing_manager.py index 86858e93d..5266142c7 100644 --- a/src/plugins/chat/willing_manager.py +++ b/src/plugins/chat/willing_manager.py @@ -60,7 +60,8 @@ class WillingManager: # if is_mentioned_bot and user_id == int(1026294844): # reply_probability = 1 - + + reply_probability = min(reply_probability, 1) return reply_probability def change_reply_willing_sent(self, group_id: int): @@ -82,4 +83,4 @@ class WillingManager: self._started = True # 创建全局实例 -willing_manager = WillingManager() \ No newline at end of file +willing_manager = WillingManager()