显示回复概率为百分数

This commit is contained in:
SengokuCola
2025-03-04 22:44:35 +08:00
committed by GitHub
2 changed files with 7 additions and 4 deletions

View File

@@ -100,7 +100,9 @@ class ChatBot:
) )
current_willing = willing_manager.get_willing(event.group_id) 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 = "" response = ""
if random() < reply_probability: if random() < reply_probability:

View File

@@ -50,7 +50,7 @@ class WillingManager:
self.group_reply_willing[group_id] = min(current_willing, 3.0) 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: if group_id not in config.talk_allowed_groups:
current_willing = 0 current_willing = 0
reply_probability = 0 reply_probability = 0
@@ -60,7 +60,8 @@ class WillingManager:
# if is_mentioned_bot and user_id == int(1026294844): # if is_mentioned_bot and user_id == int(1026294844):
# reply_probability = 1 # reply_probability = 1
reply_probability = min(reply_probability, 1)
return reply_probability return reply_probability
def change_reply_willing_sent(self, group_id: int): def change_reply_willing_sent(self, group_id: int):
@@ -82,4 +83,4 @@ class WillingManager:
self._started = True self._started = True
# 创建全局实例 # 创建全局实例
willing_manager = WillingManager() willing_manager = WillingManager()