From 77ee959821ff5c0a2a97288423c598e8ed53704b Mon Sep 17 00:00:00 2001 From: iwumingz Date: Fri, 8 Apr 2022 22:01:04 +0800 Subject: [PATCH] Convert command path to Constant --- plugins/help.py | 7 +++++-- tools/constants.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/help.py b/plugins/help.py index 47b540b..70a78d1 100644 --- a/plugins/help.py +++ b/plugins/help.py @@ -1,8 +1,10 @@ from typing import Any, Dict + import yaml from core import command from pyrogram import Client from pyrogram.types import Message +from tools.constants import COMMAND_YML from tools.helpers import Parameters @@ -10,10 +12,11 @@ from tools.helpers import Parameters async def helper(_: Client, msg: Message): """指令用法提示。格式:-help """ helper_cmd, cmd = Parameters.get(msg) - cmd_data: Dict[str, Any] = yaml.full_load(open('./data/command.yml', 'rb')) + cmd_data: Dict[str, Any] = yaml.full_load(open(COMMAND_YML, 'rb')) if not cmd: tmp = '、'.join(f"`{k}`" for k in cmd_data.keys()) - text = f"📢 **指令列表:**\n{tmp}\n\n**发送** `{helper_cmd} <{cmd}>` **查看某指令的详细用法**" + text = f"📢 **指令列表:**\n{tmp}\n\n**发送** `{helper_cmd} " \ + f"<{cmd if cmd else 'cmd'}>` **查看某指令的详细用法**" elif not cmd_data.get(cmd): text = f'❓ `{cmd}` 404 Not Found' else: diff --git a/tools/constants.py b/tools/constants.py index c6dbff0..6cebde1 100644 --- a/tools/constants.py +++ b/tools/constants.py @@ -5,6 +5,7 @@ SYCGRAM: str = "sycgram" SYCGRAM_INFO: str = f"{SYCGRAM.title()} | INFO" SYCGRAM_ERROR: str = f"{SYCGRAM.title()} | ERROR" SYCGRAM_WARNING: str = f"{SYCGRAM.title()} | WARNING" +COMMAND_YML: str = './data/command.yml' UPDATE_CMD: str = f""" docker run --rm \ -v /var/run/docker.sock:/var/run/docker.sock \