refactor(plugin_system): 移除静态PlusCommandAdapter并优化命令注册逻辑
移除了不再需要的静态`PlusCommandAdapter`类,该类最初用于将`PlusCommand`适配到旧的`BaseCommand`系统。 随着插件系统重构,所有命令(包括旧版命令)现在都统一通过动态创建的适配器在`ComponentRegistry`中转换为`PlusCommand`进行注册和处理。此更改简化了`plus_command.py`模块,消除了冗余代码,并使命令注册流程更加清晰和一致。 主要变更: - 从`plus_command.py`中删除了`PlusCommandAdapter`类。 - 调整了`ComponentRegistry`中的日志记录逻辑,现在所有旧版命令都会被明确标记并适配,无需之前的条件检查。 - 相应地更新了相关模块的导入语句。
This commit is contained in:
@@ -221,18 +221,16 @@ class ComponentRegistry:
|
||||
|
||||
def _register_command_component(self, command_info: CommandInfo, command_class: type[BaseCommand]) -> bool:
|
||||
"""注册Command组件到Command特定注册表"""
|
||||
# 检查是否为旧版Command
|
||||
if getattr(command_class, "_is_legacy", False):
|
||||
logger.warning(
|
||||
logger.warning(
|
||||
f"检测到旧版Command组件 '{command_class.command_name}' (来自插件: {command_info.plugin_name})。"
|
||||
"它将通过兼容层运行,但建议尽快迁移到PlusCommand以获得更好的性能和功能。"
|
||||
)
|
||||
# 使用适配器将其转换为PlusCommand
|
||||
adapted_class = create_legacy_command_adapter(command_class)
|
||||
plus_command_info = adapted_class.get_plus_command_info()
|
||||
plus_command_info.plugin_name = command_info.plugin_name # 继承插件名
|
||||
# 使用适配器将其转换为PlusCommand
|
||||
adapted_class = create_legacy_command_adapter(command_class)
|
||||
plus_command_info = adapted_class.get_plus_command_info()
|
||||
plus_command_info.plugin_name = command_info.plugin_name # 继承插件名
|
||||
|
||||
return self._register_plus_command_component(plus_command_info, adapted_class)
|
||||
return self._register_plus_command_component(plus_command_info, adapted_class)
|
||||
|
||||
def _register_plus_command_component(
|
||||
self, plus_command_info: PlusCommandInfo, plus_command_class: type[PlusCommand]
|
||||
|
||||
Reference in New Issue
Block a user