Merge branch 'dev' of https://github.com/MaiM-with-u/MaiBot into dev
This commit is contained in:
@@ -127,8 +127,9 @@ class ActionManager:
|
|||||||
try:
|
try:
|
||||||
# 从组件注册中心获取所有已注册的action
|
# 从组件注册中心获取所有已注册的action
|
||||||
from src.plugin_system.core.component_registry import component_registry
|
from src.plugin_system.core.component_registry import component_registry
|
||||||
|
|
||||||
action_registry = component_registry.get_action_registry()
|
action_registry = component_registry.get_action_registry()
|
||||||
|
|
||||||
# 从action_registry获取所有已注册动作
|
# 从action_registry获取所有已注册动作
|
||||||
for action_name, action_class in action_registry.items():
|
for action_name, action_class in action_registry.items():
|
||||||
# 获取动作相关信息
|
# 获取动作相关信息
|
||||||
@@ -320,6 +321,7 @@ class ActionManager:
|
|||||||
|
|
||||||
# 旧系统的动作创建逻辑
|
# 旧系统的动作创建逻辑
|
||||||
from src.plugin_system.core.component_registry import component_registry
|
from src.plugin_system.core.component_registry import component_registry
|
||||||
|
|
||||||
action_registry = component_registry.get_action_registry()
|
action_registry = component_registry.get_action_registry()
|
||||||
handler_class = action_registry.get(action_name)
|
handler_class = action_registry.get(action_name)
|
||||||
if not handler_class:
|
if not handler_class:
|
||||||
@@ -586,5 +588,6 @@ class ActionManager:
|
|||||||
Optional[Type[BaseAction]]: 动作处理器类,如果不存在则返回None
|
Optional[Type[BaseAction]]: 动作处理器类,如果不存在则返回None
|
||||||
"""
|
"""
|
||||||
from src.plugin_system.core.component_registry import component_registry
|
from src.plugin_system.core.component_registry import component_registry
|
||||||
|
|
||||||
action_registry = component_registry.get_action_registry()
|
action_registry = component_registry.get_action_registry()
|
||||||
return action_registry.get(action_name)
|
return action_registry.get(action_name)
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ logger = get_logger("hearflow_api")
|
|||||||
def _get_heartflow():
|
def _get_heartflow():
|
||||||
"""获取heartflow实例的延迟导入函数"""
|
"""获取heartflow实例的延迟导入函数"""
|
||||||
from src.chat.heart_flow.heartflow import heartflow
|
from src.chat.heart_flow.heartflow import heartflow
|
||||||
|
|
||||||
return heartflow
|
return heartflow
|
||||||
|
|
||||||
|
|
||||||
def _get_subheartflow_types():
|
def _get_subheartflow_types():
|
||||||
"""获取SubHeartflow和ChatState类型的延迟导入函数"""
|
"""获取SubHeartflow和ChatState类型的延迟导入函数"""
|
||||||
from src.chat.heart_flow.sub_heartflow import SubHeartflow, ChatState
|
from src.chat.heart_flow.sub_heartflow import SubHeartflow, ChatState
|
||||||
|
|
||||||
return SubHeartflow, ChatState
|
return SubHeartflow, ChatState
|
||||||
|
|
||||||
|
|
||||||
@@ -36,7 +38,7 @@ class HearflowAPI:
|
|||||||
"""
|
"""
|
||||||
# 使用延迟导入
|
# 使用延迟导入
|
||||||
heartflow = _get_heartflow()
|
heartflow = _get_heartflow()
|
||||||
|
|
||||||
# 直接从subheartflow_manager获取已存在的子心流
|
# 直接从subheartflow_manager获取已存在的子心流
|
||||||
# 使用锁来确保线程安全
|
# 使用锁来确保线程安全
|
||||||
async with heartflow.subheartflow_manager._lock:
|
async with heartflow.subheartflow_manager._lock:
|
||||||
@@ -130,7 +132,9 @@ class HearflowAPI:
|
|||||||
|
|
||||||
# 检查子心流是否处于FOCUSED状态且有HeartFC实例
|
# 检查子心流是否处于FOCUSED状态且有HeartFC实例
|
||||||
if subflow.chat_state.chat_status != ChatState.FOCUSED:
|
if subflow.chat_state.chat_status != ChatState.FOCUSED:
|
||||||
logger.debug(f"{self.log_prefix} 子心流 {chat_id} 未处于FOCUSED状态,当前状态: {subflow.chat_state.chat_status.value}")
|
logger.debug(
|
||||||
|
f"{self.log_prefix} 子心流 {chat_id} 未处于FOCUSED状态,当前状态: {subflow.chat_state.chat_status.value}"
|
||||||
|
)
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
if not subflow.heart_fc_instance:
|
if not subflow.heart_fc_instance:
|
||||||
@@ -140,12 +144,12 @@ class HearflowAPI:
|
|||||||
# 返回replyer和expressor实例
|
# 返回replyer和expressor实例
|
||||||
replyer = subflow.heart_fc_instance.replyer
|
replyer = subflow.heart_fc_instance.replyer
|
||||||
expressor = subflow.heart_fc_instance.expressor
|
expressor = subflow.heart_fc_instance.expressor
|
||||||
|
|
||||||
if replyer and expressor:
|
if replyer and expressor:
|
||||||
logger.debug(f"{self.log_prefix} 成功获取子心流 {chat_id} 的replyer和expressor")
|
logger.debug(f"{self.log_prefix} 成功获取子心流 {chat_id} 的replyer和expressor")
|
||||||
else:
|
else:
|
||||||
logger.warning(f"{self.log_prefix} 子心流 {chat_id} 的replyer或expressor为空")
|
logger.warning(f"{self.log_prefix} 子心流 {chat_id} 的replyer或expressor为空")
|
||||||
|
|
||||||
return replyer, expressor
|
return replyer, expressor
|
||||||
|
|
||||||
async def get_sub_hearflow_replyer(self, chat_id: str) -> Optional[Any]:
|
async def get_sub_hearflow_replyer(self, chat_id: str) -> Optional[Any]:
|
||||||
|
|||||||
Reference in New Issue
Block a user