Convert command path to Constant
This commit is contained in:
parent
3f0b0ebb5c
commit
77ee959821
@ -1,8 +1,10 @@
|
|||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from core import command
|
from core import command
|
||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
|
from tools.constants import COMMAND_YML
|
||||||
from tools.helpers import Parameters
|
from tools.helpers import Parameters
|
||||||
|
|
||||||
|
|
||||||
@ -10,10 +12,11 @@ from tools.helpers import Parameters
|
|||||||
async def helper(_: Client, msg: Message):
|
async def helper(_: Client, msg: Message):
|
||||||
"""指令用法提示。格式:-help <cmd|None>"""
|
"""指令用法提示。格式:-help <cmd|None>"""
|
||||||
helper_cmd, cmd = Parameters.get(msg)
|
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:
|
if not cmd:
|
||||||
tmp = '、'.join(f"`{k}`" for k in cmd_data.keys())
|
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):
|
elif not cmd_data.get(cmd):
|
||||||
text = f'❓ `{cmd}` 404 Not Found'
|
text = f'❓ `{cmd}` 404 Not Found'
|
||||||
else:
|
else:
|
||||||
|
@ -5,6 +5,7 @@ SYCGRAM: str = "sycgram"
|
|||||||
SYCGRAM_INFO: str = f"{SYCGRAM.title()} | INFO"
|
SYCGRAM_INFO: str = f"{SYCGRAM.title()} | INFO"
|
||||||
SYCGRAM_ERROR: str = f"{SYCGRAM.title()} | ERROR"
|
SYCGRAM_ERROR: str = f"{SYCGRAM.title()} | ERROR"
|
||||||
SYCGRAM_WARNING: str = f"{SYCGRAM.title()} | WARNING"
|
SYCGRAM_WARNING: str = f"{SYCGRAM.title()} | WARNING"
|
||||||
|
COMMAND_YML: str = './data/command.yml'
|
||||||
UPDATE_CMD: str = f"""
|
UPDATE_CMD: str = f"""
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
Loading…
Reference in New Issue
Block a user