Command dict convert to constant
This commit is contained in:
parent
2977d0a71b
commit
48e22f89d1
@ -1,4 +1,4 @@
|
|||||||
from .custom import command
|
from .custom import command, CMDS_DATA, CMDS_PREFIX
|
||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
|
|
||||||
app = Client(
|
app = Client(
|
||||||
@ -9,5 +9,8 @@ app = Client(
|
|||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'app', 'command',
|
'app',
|
||||||
|
'command',
|
||||||
|
'CMDS_DATA',
|
||||||
|
'CMDS_PREFIX',
|
||||||
)
|
)
|
||||||
|
@ -18,18 +18,18 @@ from pyrogram.types import Message
|
|||||||
from tools.constants import STORE_TRACE_DATA, COMMAND_YML
|
from tools.constants import STORE_TRACE_DATA, COMMAND_YML
|
||||||
from tools.storage import SimpleStore
|
from tools.storage import SimpleStore
|
||||||
|
|
||||||
command_data: Dict[str, Any] = yaml.full_load(open(COMMAND_YML, 'rb'))
|
CMDS_DATA: Dict[str, Any] = yaml.full_load(open(COMMAND_YML, 'rb'))
|
||||||
|
CMDS_PREFIX = CMDS_DATA.get('help').get('all_prefixes')
|
||||||
|
|
||||||
|
|
||||||
def command(key: str):
|
def command(key: str):
|
||||||
"""匹配UserBot指令"""
|
"""匹配UserBot指令"""
|
||||||
prefixes = command_data.get('help').get('all_prefixes')
|
if type(CMDS_DATA.get(key).get('cmd')) == str:
|
||||||
if type(command_data.get(key).get('cmd')) == str:
|
cmd = [CMDS_DATA.get(key).get('cmd'), key]
|
||||||
cmd = [command_data.get(key).get('cmd'), key]
|
return filters.me & filters.text & filters.command(cmd, CMDS_PREFIX)
|
||||||
return filters.me & filters.text & filters.command(cmd, prefixes)
|
|
||||||
|
|
||||||
cmd = command_data.get(key).get('cmd')
|
cmd = CMDS_DATA.get(key).get('cmd')
|
||||||
return filters.me & filters.text & filters.command(cmd, prefixes)
|
return filters.me & filters.text & filters.command(cmd, CMDS_PREFIX)
|
||||||
|
|
||||||
|
|
||||||
def is_traced():
|
def is_traced():
|
||||||
|
Loading…
Reference in New Issue
Block a user