From ae55cf5b1eb41eb7d3aa2d0112bdc1d70d6bf43d Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Fri, 7 Apr 2023 16:59:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=82=E9=85=8Dhelp=E6=8C=87?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/qqbot/cmds/system/cmds.py | 39 ----------------------------------- pkg/qqbot/cmds/system/help.py | 7 ++++++- 2 files changed, 6 insertions(+), 40 deletions(-) delete mode 100644 pkg/qqbot/cmds/system/cmds.py diff --git a/pkg/qqbot/cmds/system/cmds.py b/pkg/qqbot/cmds/system/cmds.py deleted file mode 100644 index 40d1cc2b..00000000 --- a/pkg/qqbot/cmds/system/cmds.py +++ /dev/null @@ -1,39 +0,0 @@ -from ..aamgr import AbstractCommandNode, Context, __command_list__ - - -@AbstractCommandNode.register( - parent=None, - name="cmd", - description="显示指令列表", - usage="!help\n!help <指令名称>", - aliases=[], - privilege=1 -) -class CmdCommand(AbstractCommandNode): - @classmethod - def process(cls, ctx: Context) -> tuple[bool, list]: - command_list = __command_list__ - - reply = [] - - if len(ctx.params) == 0: - reply_str = "[bot]当前所有指令:\n\n" - - # 遍历顶级指令 - for key in command_list: - command = command_list[key] - if command['parent'] is None: - reply_str += "!{} - {}\n".format(key, command['description']) - - reply_str += "\n请使用 !cmd <指令名称> 来查看指令的详细信息" - - reply = [reply_str] - else: - command_name = ctx.params[0] - if command_name in command_list: - reply = [command_list[command_name]['cls'].help()] - else: - reply = ["[bot]指令 {} 不存在".format(command_name)] - - return True, reply - \ No newline at end of file diff --git a/pkg/qqbot/cmds/system/help.py b/pkg/qqbot/cmds/system/help.py index 72e06d71..798cbf58 100644 --- a/pkg/qqbot/cmds/system/help.py +++ b/pkg/qqbot/cmds/system/help.py @@ -12,8 +12,13 @@ from ..aamgr import AbstractCommandNode, Context class HelpCommand(AbstractCommandNode): @classmethod def process(cls, ctx: Context) -> tuple[bool, list]: + import tips + reply = ["[bot] "+tips.help_message + "\n请输入 !cmd 查看指令列表"] + + # 警告config.help_message过时 import config - reply = [(config.help_message) + "\n请输入 !cmds 查看指令列表"] + if hasattr(config, "help_message"): + reply[0] += "\n\n警告:config.py中的help_message已过时,不再生效,请使用tips.py中的help_message替代" return True, reply \ No newline at end of file