From d58cf9c819e2f19116559d3544284d126d6ca75a Mon Sep 17 00:00:00 2001 From: UnCLAS-Prommer Date: Thu, 24 Jul 2025 00:42:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/built_in/plugin_management/plugin.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/built_in/plugin_management/plugin.py b/src/plugins/built_in/plugin_management/plugin.py index 353afe7f1..67e2a5f66 100644 --- a/src/plugins/built_in/plugin_management/plugin.py +++ b/src/plugins/built_in/plugin_management/plugin.py @@ -22,6 +22,14 @@ class ManagementCommand(BaseCommand): async def execute(self) -> Tuple[bool, str]: # sourcery skip: merge-duplicate-blocks + if ( + not self.message + or not self.message.message_info + or not self.message.message_info.user_info + or str(self.message.message_info.user_info.user_id) not in self.get_config("plugin.permission", []) # type: ignore + ): + await self.send_text("你没有权限使用插件管理命令") + return False, "没有权限" command_list = self.matched_groups["manage_command"].strip().split(" ") if len(command_list) == 1: await self.show_help("all") @@ -419,7 +427,12 @@ class PluginManagementPlugin(BasePlugin): dependencies: list[str] = [] python_dependencies: list[str] = [] config_file_name: str = "config.toml" - config_schema: dict = {"plugin": {"enable": ConfigField(bool, default=True, description="是否启用插件")}} + config_schema: dict = { + "plugin": { + "enable": ConfigField(bool, default=True, description="是否启用插件"), + "permission": ConfigField(list, default=[], description="有权限使用插件管理命令的用户列表"), + }, + } def get_plugin_components(self) -> List[Tuple[CommandInfo, Type[BaseCommand]]]: components = []