fix:修正merge带来的问题

This commit is contained in:
SengokuCola
2025-07-13 13:46:12 +08:00
parent 5fd4caf23b
commit aafa4c688b
6 changed files with 22 additions and 6 deletions

0
s4u.s4u1 Normal file
View File

View File

@@ -142,7 +142,7 @@ class ActionModifier:
async def _get_deactivated_actions_by_type(
self,
actions_with_info: Dict[str, Any],
actions_with_info: Dict[str, ActionInfo],
chat_content: str = "",
) -> List[tuple[str, str]]:
"""
@@ -164,7 +164,7 @@ class ActionModifier:
random.shuffle(actions_to_check)
for action_name, action_info in actions_to_check:
activation_type = action_info.get("activation_type", "")
activation_type = action_info.activation_type
if not activation_type:
activation_type = action_info.get("focus_activation_type", "")

View File

@@ -95,7 +95,7 @@ class BaseWillingManager(ABC):
def setup(self, message: dict, chat: ChatStream):
person_id = PersonInfoManager.get_person_id(chat.platform, chat.user_info.user_id) # type: ignore
self.ongoing_messages[message.message_info.message_id] = WillingInfo( # type: ignore
self.ongoing_messages[message.get("message_id", "")] = WillingInfo( # type: ignore
message=message,
chat=chat,
person_info_manager=get_person_info_manager(),

View File

@@ -367,12 +367,25 @@ class BaseAction(ABC):
return getattr(ChatMode, default.upper(), ChatMode.ALL)
return attr
# 获取focus_activation_type和normal_activation_type
focus_activation_type = get_enum_value("focus_activation_type", "always")
normal_activation_type = get_enum_value("normal_activation_type", "always")
# 处理activation_type如果插件中声明了就用插件的值否则默认使用focus_activation_type
activation_type = getattr(cls, "activation_type", None)
if activation_type is None:
activation_type = focus_activation_type
elif not hasattr(activation_type, "value"):
# 如果是字符串,转换为对应的枚举
activation_type = getattr(ActionActivationType, activation_type.upper(), focus_activation_type)
return ActionInfo(
name=name,
component_type=ComponentType.ACTION,
description=description,
focus_activation_type=get_enum_value("focus_activation_type", "always"),
normal_activation_type=get_enum_value("normal_activation_type", "always"),
focus_activation_type=focus_activation_type,
normal_activation_type=normal_activation_type,
activation_type=activation_type,
activation_keywords=getattr(cls, "activation_keywords", []).copy(),
keyword_case_sensitive=getattr(cls, "keyword_case_sensitive", False),
mode_enable=get_mode_value("mode_enable", "all"),

View File

@@ -89,6 +89,7 @@ class ActionInfo(ComponentInfo):
# 激活类型相关
focus_activation_type: ActionActivationType = ActionActivationType.ALWAYS
normal_activation_type: ActionActivationType = ActionActivationType.ALWAYS
activation_type: ActionActivationType = ActionActivationType.ALWAYS
random_activation_probability: float = 0.0
llm_judge_prompt: str = ""
activation_keywords: List[str] = field(default_factory=list) # 激活关键词列表

View File

@@ -10,6 +10,7 @@ import time
from typing import List, Tuple, Type
import asyncio
import re
import traceback
# 导入新插件系统
from src.plugin_system import BasePlugin, register_plugin, BaseAction, ComponentInfo, ActionActivationType, ChatMode
@@ -77,7 +78,7 @@ class ReplyAction(BaseAction):
try:
try:
success, reply_set = await asyncio.wait_for(
success, reply_set, _ = await asyncio.wait_for(
generator_api.generate_reply(
action_data=self.action_data,
chat_id=self.chat_id,
@@ -138,6 +139,7 @@ class ReplyAction(BaseAction):
except Exception as e:
logger.error(f"{self.log_prefix} 回复动作执行失败: {e}")
traceback.print_exc()
return False, f"回复失败: {str(e)}"