添加私聊过滤开关,更新config,增加约束
This commit is contained in:
@@ -31,7 +31,6 @@ from .willing_manager import willing_manager # 导入意愿管理器
|
|||||||
from .message_base import UserInfo, GroupInfo, Seg
|
from .message_base import UserInfo, GroupInfo, Seg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ChatBot:
|
class ChatBot:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.storage = MessageStorage()
|
self.storage = MessageStorage()
|
||||||
@@ -59,7 +58,7 @@ class ChatBot:
|
|||||||
|
|
||||||
# 处理私聊消息的逻辑
|
# 处理私聊消息的逻辑
|
||||||
if isinstance(event, PrivateMessageEvent):
|
if isinstance(event, PrivateMessageEvent):
|
||||||
if not 0 in global_config.talk_allowed_groups:
|
if not global_config.enable_friend_chat: # 私聊过滤
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
user_info = UserInfo(
|
user_info = UserInfo(
|
||||||
@@ -182,7 +181,6 @@ class ChatBot:
|
|||||||
)
|
)
|
||||||
current_willing = willing_manager.get_willing(chat_stream=chat)
|
current_willing = willing_manager.get_willing(chat_stream=chat)
|
||||||
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"[{current_time}][{chat.group_info.group_name if chat.group_info.group_id else '私聊'}]{chat.user_info.user_nickname}:"
|
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}%]"
|
f"{message.processed_plain_text}[回复意愿:{current_willing:.2f}][概率:{reply_probability * 100:.1f}%]"
|
||||||
@@ -190,7 +188,6 @@ class ChatBot:
|
|||||||
|
|
||||||
response = None
|
response = None
|
||||||
|
|
||||||
|
|
||||||
if random() < reply_probability:
|
if random() < reply_probability:
|
||||||
bot_user_info = UserInfo(
|
bot_user_info = UserInfo(
|
||||||
user_id=global_config.BOT_QQ,
|
user_id=global_config.BOT_QQ,
|
||||||
@@ -206,14 +203,12 @@ class ChatBot:
|
|||||||
reply=message,
|
reply=message,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
message_manager.add_message(thinking_message)
|
message_manager.add_message(thinking_message)
|
||||||
|
|
||||||
willing_manager.change_reply_willing_sent(chat)
|
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)
|
||||||
|
|
||||||
|
|
||||||
response, raw_content = await self.gpt.generate_response(message)
|
response, raw_content = await self.gpt.generate_response(message)
|
||||||
|
|
||||||
# print(f"response: {response}")
|
# print(f"response: {response}")
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ class BotConfig:
|
|||||||
enable_advance_output: bool = False # 是否启用高级输出
|
enable_advance_output: bool = False # 是否启用高级输出
|
||||||
enable_kuuki_read: bool = True # 是否启用读空气功能
|
enable_kuuki_read: bool = True # 是否启用读空气功能
|
||||||
enable_debug_output: bool = False # 是否启用调试输出
|
enable_debug_output: bool = False # 是否启用调试输出
|
||||||
|
enable_friend_chat: bool = False # 是否启用好友聊天
|
||||||
|
|
||||||
mood_update_interval: float = 1.0 # 情绪更新间隔 单位秒
|
mood_update_interval: float = 1.0 # 情绪更新间隔 单位秒
|
||||||
mood_decay_rate: float = 0.95 # 情绪衰减率
|
mood_decay_rate: float = 0.95 # 情绪衰减率
|
||||||
@@ -327,7 +328,9 @@ class BotConfig:
|
|||||||
others_config = parent["others"]
|
others_config = parent["others"]
|
||||||
config.enable_advance_output = others_config.get("enable_advance_output", config.enable_advance_output)
|
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_kuuki_read = others_config.get("enable_kuuki_read", config.enable_kuuki_read)
|
||||||
|
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_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
|
# 版本表达式:>=1.0.0,<2.0.0
|
||||||
# 允许字段:func: method, support: str, notice: str, necessary: bool
|
# 允许字段:func: method, support: str, notice: str, necessary: bool
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[inner]
|
[inner]
|
||||||
version = "0.0.6"
|
version = "0.0.7"
|
||||||
|
|
||||||
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
||||||
#如果新增项目,请在BotConfig类下新增相应的变量
|
#如果新增项目,请在BotConfig类下新增相应的变量
|
||||||
@@ -101,6 +101,7 @@ word_replace_rate=0.006 # 整词替换概率
|
|||||||
enable_advance_output = true # 是否启用高级输出
|
enable_advance_output = true # 是否启用高级输出
|
||||||
enable_kuuki_read = true # 是否启用读空气功能
|
enable_kuuki_read = true # 是否启用读空气功能
|
||||||
enable_debug_output = false # 是否启用调试输出
|
enable_debug_output = false # 是否启用调试输出
|
||||||
|
enable_friend_chat = false # 是否启用好友聊天
|
||||||
|
|
||||||
[groups]
|
[groups]
|
||||||
talk_allowed = [
|
talk_allowed = [
|
||||||
|
|||||||
Reference in New Issue
Block a user