Convert command path to Constant
This commit is contained in:
parent
3f0b0ebb5c
commit
77ee959821
@ -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 <cmd|None>"""
|
||||
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:
|
||||
|
@ -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user