From 73dccb21f577302cb4f80e2b9abea06593512d46 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Thu, 30 Mar 2023 11:29:04 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E6=9D=83=E9=99=90=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmdpriv-template.json | 28 ++++++++++++++++++++++++++++ generate_cmdpriv_template.py | 17 +++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 cmdpriv-template.json create mode 100644 generate_cmdpriv_template.py diff --git a/cmdpriv-template.json b/cmdpriv-template.json new file mode 100644 index 00000000..f1855743 --- /dev/null +++ b/cmdpriv-template.json @@ -0,0 +1,28 @@ +{ + "comment": "以下为命令权限,请设置到cmdpriv.json中: 1为所有用户可用,2为仅管理员可用。", + "draw": 1, + "plugin": 2, + "plugin.get": 2, + "plugin.update": 2, + "plugin.del": 2, + "plugin.off": 2, + "plugin.on": 2, + "default": 1, + "default.set": 2, + "del": 1, + "del.all": 1, + "delhst": 2, + "delhst.all": 2, + "last": 1, + "list": 1, + "next": 1, + "prompt": 1, + "resend": 1, + "reset": 1, + "cfg": 2, + "help": 1, + "reload": 2, + "update": 2, + "usage": 1, + "version": 1 +} \ No newline at end of file diff --git a/generate_cmdpriv_template.py b/generate_cmdpriv_template.py new file mode 100644 index 00000000..1f793adc --- /dev/null +++ b/generate_cmdpriv_template.py @@ -0,0 +1,17 @@ +import pkg.qqbot.cmds.mgr as cmdsmgr +import json + +# 执行命令模块的注册 +cmdsmgr.register_all() + +# 生成限权文件模板 +template: dict[str, int] = { + "comment": "以下为命令权限,请设置到cmdpriv.json中: 1为所有用户可用,2为仅管理员可用。", +} + +for key in cmdsmgr.__command_list__: + template[key] = cmdsmgr.__command_list__[key]['privilege'] + +# 写入cmdpriv-template.json +with open('cmdpriv-template.json', 'w') as f: + f.write(json.dumps(template, indent=4, ensure_ascii=False)) \ No newline at end of file