feat(system): 为系统管理命令添加权限控制

为 `system` 命令添加了 `system.access` 权限节点,并为 `execute` 方法增加了权限检查。现在只有拥有 `system.access` 权限的用户才能执行系统管理相关操作,提升了机器人的安全性。
This commit is contained in:
minecraft1024a
2025-11-02 12:46:20 +08:00
parent 74194148d0
commit c94566fd1c

View File

@@ -41,6 +41,7 @@ class SystemCommand(PlusCommand):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@require_permission("system.access", "❌ 你没有权限使用此命令")
async def execute(self, args: CommandArgs) -> tuple[bool, str | None, bool]:
"""执行系统管理命令"""
if args.is_empty:
@@ -508,6 +509,10 @@ class SystemManagementPlugin(BasePlugin):
return [(SystemCommand.get_plus_command_info(), SystemCommand)]
permission_nodes: ClassVar[list[PermissionNodeField]] = [
PermissionNodeField(
node_name="system.access",
description="权限管理:授权和撤销权限",
),
PermissionNodeField(
node_name="permission.manage",
description="权限管理:授权和撤销权限",