加载冲突导致不正常了。
This commit is contained in:
@@ -50,14 +50,6 @@ class PluginManagerPlugin(MessagePluginInterface):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.plugin_manager = None
|
||||
self.plugin_registry = None
|
||||
self.wcf = None
|
||||
self.event_system = None
|
||||
self.message_util = None
|
||||
self._commands = []
|
||||
self.command_format = ""
|
||||
self.enable = True
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
"""初始化插件"""
|
||||
@@ -69,17 +61,6 @@ class PluginManagerPlugin(MessagePluginInterface):
|
||||
self.event_system = context.get("event_system")
|
||||
self.message_util = context.get("message_util")
|
||||
|
||||
# 保存插件注册表引用,用于管理插件
|
||||
self.plugin_registry: PluginRegistry = context.get("plugin_registry")
|
||||
if not self.plugin_registry:
|
||||
self.LOG.error("无法获取插件注册表,插件管理功能将无法正常工作")
|
||||
return False
|
||||
|
||||
# 创建插件管理器实例
|
||||
self.plugin_manager = PluginManager().get_instance()
|
||||
# 设置系统上下文
|
||||
self.plugin_manager.set_system_context(context)
|
||||
|
||||
self._commands = self._config.get("PluginManager", {}).get("command", ["插件", "plugin", "插件管理"])
|
||||
self.command_format = self._config.get("PluginManager", {}).get("command-format", "插件 列表")
|
||||
self.enable = self._config.get("PluginManager", {}).get("enable", True)
|
||||
@@ -115,7 +96,9 @@ class PluginManagerPlugin(MessagePluginInterface):
|
||||
if len(parts) == 1:
|
||||
wcf.send_text(f"❌命令格式错误!\n{self.command_format}", target, sender)
|
||||
return True, "命令格式错误"
|
||||
|
||||
# 只有使用的时候才全局获取对象。防止在预加载的时候跟主线程冲突
|
||||
self.plugin_registry = PluginRegistry()
|
||||
self.plugin_manager = PluginManager().get_instance()
|
||||
# 检查权限 (只允许管理员操作)
|
||||
if not self._is_admin(sender, gbm):
|
||||
wcf.send_text(f"❌权限不足,只有管理员可以管理插件", target, sender)
|
||||
|
||||
Reference in New Issue
Block a user