2022-04-09 05:35:49 +00:00
|
|
|
from core import CMDS_DATA, command
|
2022-04-06 14:39:27 +00:00
|
|
|
from pyrogram import Client
|
|
|
|
from pyrogram.types import Message
|
2022-04-07 04:06:13 +00:00
|
|
|
from tools.helpers import Parameters
|
2022-04-06 14:39:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@Client.on_message(command('help'))
|
|
|
|
async def helper(_: Client, msg: Message):
|
|
|
|
"""指令用法提示。格式:-help <cmd|None>"""
|
2022-04-07 04:06:13 +00:00
|
|
|
helper_cmd, cmd = Parameters.get(msg)
|
2022-04-09 05:35:49 +00:00
|
|
|
data = CMDS_DATA
|
|
|
|
cmd_alias = dict(zip((v.get('cmd') for v in data.values()), data.keys()))
|
2022-04-06 14:39:27 +00:00
|
|
|
if not cmd:
|
2022-04-09 05:35:49 +00:00
|
|
|
tmp = '、'.join(f"`{k}`" for k in data.keys())
|
2022-04-08 14:01:04 +00:00
|
|
|
text = f"📢 **指令列表:**\n{tmp}\n\n**发送** `{helper_cmd} " \
|
|
|
|
f"<{cmd if cmd else 'cmd'}>` **查看某指令的详细用法**"
|
2022-04-09 05:35:49 +00:00
|
|
|
elif not data.get(cmd) and cmd not in cmd_alias:
|
|
|
|
text = f"❗️ Without this command >>> `{cmd}`"
|
2022-04-06 14:39:27 +00:00
|
|
|
else:
|
2022-04-09 05:35:49 +00:00
|
|
|
key = cmd if data.get(cmd) else cmd_alias.get(cmd)
|
|
|
|
text = f"格式:`{data.get(key).get('format')}`\n" \
|
|
|
|
f"用法:`{data.get(key).get('usage')}`"
|
2022-04-06 14:39:27 +00:00
|
|
|
await msg.edit_text(text, parse_mode='md')
|