修复正则,更改一下template注释
This commit is contained in:
@@ -1,18 +1,21 @@
|
|||||||
import traceback
|
from src.chat.memory_system.Hippocampus import HippocampusManager
|
||||||
from ..memory_system.Hippocampus import HippocampusManager
|
from src.config.config import global_config
|
||||||
from ...config.config import global_config
|
from src.chat.message_receive.message import MessageRecv
|
||||||
from ..message_receive.message import MessageRecv
|
from src.chat.message_receive.storage import MessageStorage
|
||||||
from ..message_receive.storage import MessageStorage
|
|
||||||
from ..utils.utils import is_mentioned_bot_in_message
|
|
||||||
from src.chat.heart_flow.heartflow import heartflow
|
from src.chat.heart_flow.heartflow import heartflow
|
||||||
|
from src.chat.message_receive.chat_stream import chat_manager, ChatStream
|
||||||
|
from src.chat.utils.utils import is_mentioned_bot_in_message
|
||||||
|
from src.chat.utils.timer_calculator import Timer
|
||||||
from src.common.logger_manager import get_logger
|
from src.common.logger_manager import get_logger
|
||||||
from ..message_receive.chat_stream import chat_manager
|
from src.person_info.relationship_manager import relationship_manager
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
import re
|
||||||
|
import traceback
|
||||||
|
from typing import Optional, Tuple, Dict, Any
|
||||||
|
from maim_message import UserInfo
|
||||||
|
|
||||||
# from ..message_receive.message_buffer import message_buffer
|
# from ..message_receive.message_buffer import message_buffer
|
||||||
from ..utils.timer_calculator import Timer
|
|
||||||
from src.person_info.relationship_manager import relationship_manager
|
|
||||||
from typing import Optional, Tuple, Dict, Any
|
|
||||||
|
|
||||||
logger = get_logger("chat")
|
logger = get_logger("chat")
|
||||||
|
|
||||||
@@ -109,7 +112,7 @@ async def _calculate_interest(message: MessageRecv) -> Tuple[float, bool]:
|
|||||||
# return "seglist"
|
# return "seglist"
|
||||||
|
|
||||||
|
|
||||||
def _check_ban_words(text: str, chat, userinfo) -> bool:
|
def _check_ban_words(text: str, chat: ChatStream, userinfo: UserInfo) -> bool:
|
||||||
"""检查消息是否包含过滤词
|
"""检查消息是否包含过滤词
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -129,7 +132,7 @@ def _check_ban_words(text: str, chat, userinfo) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _check_ban_regex(text: str, chat, userinfo) -> bool:
|
def _check_ban_regex(text: str, chat: ChatStream, userinfo: UserInfo) -> bool:
|
||||||
"""检查消息是否匹配过滤正则表达式
|
"""检查消息是否匹配过滤正则表达式
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -141,7 +144,7 @@ def _check_ban_regex(text: str, chat, userinfo) -> bool:
|
|||||||
bool: 是否匹配过滤正则
|
bool: 是否匹配过滤正则
|
||||||
"""
|
"""
|
||||||
for pattern in global_config.message_receive.ban_msgs_regex:
|
for pattern in global_config.message_receive.ban_msgs_regex:
|
||||||
if pattern.search(text):
|
if re.search(pattern, text):
|
||||||
chat_name = chat.group_info.group_name if chat.group_info else "私聊"
|
chat_name = chat.group_info.group_name if chat.group_info else "私聊"
|
||||||
logger.info(f"[{chat_name}]{userinfo.user_nickname}:{text}")
|
logger.info(f"[{chat_name}]{userinfo.user_nickname}:{text}")
|
||||||
logger.info(f"[正则表达式过滤]消息匹配到{pattern},filtered")
|
logger.info(f"[正则表达式过滤]消息匹配到{pattern},filtered")
|
||||||
|
|||||||
@@ -65,10 +65,9 @@ ban_words = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
ban_msgs_regex = [
|
ban_msgs_regex = [
|
||||||
# 需要过滤的消息(原始消息)匹配的正则表达式,匹配到的消息将被过滤(支持CQ码),若不了解正则表达式请勿修改
|
# 需要过滤的消息(原始消息)匹配的正则表达式,匹配到的消息将被过滤,若不了解正则表达式请勿修改
|
||||||
#"https?://[^\\s]+", # 匹配https链接
|
#"https?://[^\\s]+", # 匹配https链接
|
||||||
#"\\d{4}-\\d{2}-\\d{2}", # 匹配日期
|
#"\\d{4}-\\d{2}-\\d{2}", # 匹配日期
|
||||||
# "\\[CQ:at,qq=\\d+\\]" # 匹配@
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[normal_chat] #普通聊天
|
[normal_chat] #普通聊天
|
||||||
@@ -95,7 +94,7 @@ talk_frequency_down_groups = [] #降低回复频率的群号码
|
|||||||
think_interval = 3 # 思考间隔 单位秒,可以有效减少消耗
|
think_interval = 3 # 思考间隔 单位秒,可以有效减少消耗
|
||||||
|
|
||||||
observation_context_size = 15 # 观察到的最长上下文大小,建议15,太短太长都会导致脑袋尖尖
|
observation_context_size = 15 # 观察到的最长上下文大小,建议15,太短太长都会导致脑袋尖尖
|
||||||
compressed_length = 5 # 不能大于chat.observation_context_size,心流上下文压缩的最短压缩长度,超过心流观察到的上下文长度,会压缩,最短压缩长度为5
|
compressed_length = 5 # 不能大于observation_context_size,心流上下文压缩的最短压缩长度,超过心流观察到的上下文长度,会压缩,最短压缩长度为5
|
||||||
compress_length_limit = 5 #最多压缩份数,超过该数值的压缩上下文会被删除
|
compress_length_limit = 5 #最多压缩份数,超过该数值的压缩上下文会被删除
|
||||||
|
|
||||||
[focus_chat_processor] # 专注聊天处理器,打开可以实现更多功能,但是会增加token消耗
|
[focus_chat_processor] # 专注聊天处理器,打开可以实现更多功能,但是会增加token消耗
|
||||||
|
|||||||
Reference in New Issue
Block a user