diff --git a/astrbot/core/star/config.py b/astrbot/core/star/config.py index 914b2498f..83bb9f4cb 100644 --- a/astrbot/core/star/config.py +++ b/astrbot/core/star/config.py @@ -1,3 +1,7 @@ +''' +此功能已过时,参考 https://astrbot.app/dev/plugin.html#%E6%B3%A8%E5%86%8C%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE-beta +''' + from typing import Union import os import json diff --git a/astrbot/core/star/context.py b/astrbot/core/star/context.py index 9dfb7bf5d..6b50f951c 100644 --- a/astrbot/core/star/context.py +++ b/astrbot/core/star/context.py @@ -10,7 +10,7 @@ from astrbot.core.platform.astr_message_event import MessageSesion from astrbot.core.message.message_event_result import MessageChain from astrbot.core.provider.manager import ProviderManager from astrbot.core.platform.manager import PlatformManager -from .star import star_registry, StarMetadata +from .star import star_registry, StarMetadata, star_map from .star_handler import star_handlers_registry, StarHandlerMetadata, EventType from .filter.command import CommandFilter from .filter.regex import RegexFilter @@ -75,6 +75,11 @@ class Context: ''' func_tool = self.provider_manager.llm_tools.get_func(name) if func_tool is not None: + + if func_tool.handler_module_path in star_map: + if not star_map[func_tool.handler_module_path].activated: + raise ValueError(f"此函数调用工具所属的插件 {star_map[func_tool.handler_module_path].name} 已被禁用,请先在管理面板启用再激活此工具。") + func_tool.active = True inactivated_llm_tools: list = sp.get("inactivated_llm_tools", []) diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index 6ad4c3976..4f6bbb398 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -327,13 +327,14 @@ class PluginManager: if plugin.module_path not in inactivated_plugins: inactivated_plugins.append(plugin.module_path) - inactivated_llm_tools: list = sp.get("inactivated_llm_tools", []) + inactivated_llm_tools: list = list(set(sp.get("inactivated_llm_tools", []))) # 后向兼容 # 禁用插件启用的 llm_tool for func_tool in llm_tools.func_list: if func_tool.handler_module_path == plugin.module_path: func_tool.active = False - inactivated_llm_tools.append(func_tool.name) + if func_tool.name not in inactivated_llm_tools: + inactivated_llm_tools.append(func_tool.name) sp.put("inactivated_plugins", inactivated_plugins) sp.put("inactivated_llm_tools", inactivated_llm_tools)