模块管理优化
This commit is contained in:
@@ -178,19 +178,19 @@ class PluginManagerPlugin(MessagePluginInterface):
|
||||
target = roomid if roomid else sender
|
||||
|
||||
# 查找匹配的插件名称
|
||||
actual_plugin_name = self.plugin_manager.find_plugin_by_name(plugin_name)
|
||||
display_name, plugin = self.plugin_manager.find_plugin_by_name(plugin_name)
|
||||
|
||||
if not actual_plugin_name:
|
||||
if not display_name:
|
||||
wcf.send_text(f"❌未找到插件 {plugin_name},请检查名称是否正确", target, sender)
|
||||
return True, f"未找到插件 {plugin_name}"
|
||||
|
||||
# 不允许操作自身(对于某些操作)
|
||||
if actual_plugin_name == self.name and operation_func in [self._unload_plugin, self._disable_plugin]:
|
||||
if display_name == self.name and operation_func in [self._unload_plugin, self._disable_plugin]:
|
||||
wcf.send_text(f"⚠️不能对插件管理插件自身执行此操作", target, sender)
|
||||
return True, "不能对插件管理插件自身执行此操作"
|
||||
|
||||
# 执行具体操作
|
||||
return operation_func(actual_plugin_name, wcf, sender, roomid)
|
||||
return operation_func(display_name, wcf, sender, roomid)
|
||||
|
||||
def _enable_plugin(self, plugin_name: str, wcf, sender: str, roomid: str) -> Tuple[bool, str]:
|
||||
"""启用插件"""
|
||||
@@ -328,18 +328,18 @@ class PluginManagerPlugin(MessagePluginInterface):
|
||||
def _plugin_info(self, plugin_name: str, wcf, sender: str, roomid: str) -> Tuple[bool, str]:
|
||||
"""查看插件详情"""
|
||||
# 查找匹配的插件名称
|
||||
actual_plugin_name = self.plugin_manager.find_plugin_by_name(plugin_name)
|
||||
display_name, plugin = self.plugin_manager.find_plugin_by_name(plugin_name)
|
||||
|
||||
if not actual_plugin_name:
|
||||
if not display_name:
|
||||
wcf.send_text(f"❌未找到插件 {plugin_name},请检查名称是否正确",
|
||||
(roomid if roomid else sender), sender)
|
||||
return True, f"未找到插件 {plugin_name}"
|
||||
|
||||
plugin = self.plugin_registry.get_plugin(actual_plugin_name)
|
||||
plugin = self.plugin_registry.get_plugin(display_name)
|
||||
if not plugin:
|
||||
wcf.send_text(f"❌插件 {actual_plugin_name} 不存在",
|
||||
wcf.send_text(f"❌插件 {display_name} 不存在",
|
||||
(roomid if roomid else sender), sender)
|
||||
return True, f"插件 {actual_plugin_name} 不存在"
|
||||
return True, f"插件 {display_name} 不存在"
|
||||
|
||||
# 获取插件模块名
|
||||
module_name = plugin.__class__.__module__.split('.')[-2]
|
||||
|
||||
Reference in New Issue
Block a user