fix ruff
This commit is contained in:
@@ -13,7 +13,6 @@ from src.chat.utils.prompt_builder import Prompt, global_prompt_manager
|
||||
from src.chat.utils.chat_message_builder import (
|
||||
build_readable_actions,
|
||||
get_actions_by_timestamp_with_chat,
|
||||
build_readable_messages,
|
||||
build_readable_messages_with_id,
|
||||
get_raw_msg_before_timestamp_with_chat,
|
||||
)
|
||||
@@ -108,6 +107,7 @@ class ActionPlanner:
|
||||
reasoning = "规划器初始化默认"
|
||||
action_data = {}
|
||||
current_available_actions: Dict[str, ActionInfo] = {}
|
||||
target_message = None # 初始化target_message变量
|
||||
|
||||
try:
|
||||
is_group_chat = True
|
||||
@@ -202,8 +202,6 @@ class ActionPlanner:
|
||||
target_message = self.find_message_by_id(target_message_id, message_id_list)
|
||||
else:
|
||||
logger.warning(f"{self.log_prefix}FOCUS模式下动作'{action}'缺少target_message_id")
|
||||
else:
|
||||
target_message = None
|
||||
|
||||
if action == "no_action":
|
||||
reasoning = "normal决定不使用额外动作"
|
||||
@@ -293,6 +291,7 @@ class ActionPlanner:
|
||||
- 如果你刚刚进行了回复,不要对同一个话题重复回应
|
||||
{
|
||||
"action": "reply",
|
||||
"target_message_id":"触发action的消息id",
|
||||
"reason":"回复的原因"
|
||||
}
|
||||
|
||||
|
||||
@@ -185,8 +185,6 @@ class DefaultReplyer:
|
||||
prompt = None
|
||||
if available_actions is None:
|
||||
available_actions = {}
|
||||
if reply_data is None:
|
||||
reply_data = {}
|
||||
try:
|
||||
if not reply_data:
|
||||
reply_data = {
|
||||
|
||||
@@ -252,7 +252,7 @@ def _build_readable_messages_internal(
|
||||
pic_id_mapping: Optional[Dict[str, str]] = None,
|
||||
pic_counter: int = 1,
|
||||
show_pic: bool = True,
|
||||
message_id_list: List[Dict[str, Any]] = [],
|
||||
message_id_list: List[Dict[str, Any]] = None,
|
||||
) -> Tuple[str, List[Tuple[float, str, str]], Dict[str, str], int]:
|
||||
"""
|
||||
内部辅助函数,构建可读消息字符串和原始消息详情列表。
|
||||
@@ -697,7 +697,7 @@ def build_readable_messages(
|
||||
truncate: bool = False,
|
||||
show_actions: bool = False,
|
||||
show_pic: bool = True,
|
||||
message_id_list: List[Dict[str, Any]] = [],
|
||||
message_id_list: List[Dict[str, Any]] = None,
|
||||
) -> str: # sourcery skip: extract-method
|
||||
"""
|
||||
将消息列表转换为可读的文本格式。
|
||||
|
||||
@@ -77,7 +77,7 @@ def find_messages(
|
||||
query = query.where(Messages.user_id != global_config.bot.qq_account)
|
||||
|
||||
if filter_command:
|
||||
query = query.where(Messages.is_command == False)
|
||||
query = query.where(not Messages.is_command)
|
||||
|
||||
if limit > 0:
|
||||
if limit_mode == "earliest":
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import List, Dict, Type
|
||||
|
||||
class BaseEventsPlugin(ABC):
|
||||
"""
|
||||
|
||||
@@ -24,7 +24,7 @@ from src.common.logger import get_logger
|
||||
from src.plugin_system.apis import generator_api, message_api
|
||||
from src.plugins.built_in.core_actions.no_reply import NoReplyAction
|
||||
from src.plugins.built_in.core_actions.emoji import EmojiAction
|
||||
from src.person_info.person_info import person_info_manager
|
||||
from src.person_info.person_info import get_person_info_manager
|
||||
|
||||
logger = get_logger("core_actions")
|
||||
|
||||
@@ -72,10 +72,12 @@ class ReplyAction(BaseAction):
|
||||
|
||||
user_id = self.user_id
|
||||
platform = self.platform
|
||||
person_id = person_info_manager.get_person_id(user_id, platform)
|
||||
|
||||
person_name = person_info_manager.get_value(person_id, "person_name")
|
||||
# logger.info(f"{self.log_prefix} 用户ID: {user_id}, 平台: {platform}")
|
||||
person_id = get_person_info_manager().get_person_id(platform, user_id)
|
||||
# logger.info(f"{self.log_prefix} 人物ID: {person_id}")
|
||||
person_name = get_person_info_manager().get_value_sync(person_id, "person_name")
|
||||
reply_to = f"{person_name}:{self.action_message.get('processed_plain_text', '')}"
|
||||
logger.info(f"{self.log_prefix} 回复目标: {reply_to}")
|
||||
|
||||
try:
|
||||
prepared_reply = self.action_data.get("prepared_reply", "")
|
||||
@@ -83,7 +85,7 @@ class ReplyAction(BaseAction):
|
||||
try:
|
||||
success, reply_set, _ = await asyncio.wait_for(
|
||||
generator_api.generate_reply(
|
||||
action_data=self.action_data,
|
||||
extra_info="",
|
||||
reply_to=reply_to,
|
||||
chat_id=self.chat_id,
|
||||
request_type="chat.replyer.focus",
|
||||
|
||||
Reference in New Issue
Block a user