Moved to async
This commit is contained in:
@@ -3,7 +3,8 @@ from pyrogram.client import Client
|
||||
from pyrogram.types import BotCommand, BotCommandScopeChat
|
||||
from modules.utils import configGet, locale
|
||||
|
||||
def register_commands(app: Client):
|
||||
async def register_commands(app: Client):
|
||||
|
||||
if configGet("submit", "mode"):
|
||||
# Registering user commands
|
||||
for entry in listdir(configGet("locale", "locations")):
|
||||
@@ -11,19 +12,22 @@ def register_commands(app: Client):
|
||||
commands_list = []
|
||||
for command in configGet("commands"):
|
||||
commands_list.append(BotCommand(command, locale(command, "commands", locale=entry.replace(".json", ""))))
|
||||
app.set_bot_commands(commands_list, language_code=entry.replace(".json", ""))
|
||||
await app.set_bot_commands(commands_list, language_code=entry.replace(".json", ""))
|
||||
|
||||
# Registering user commands for fallback locale
|
||||
commands_list = []
|
||||
for command in configGet("commands"):
|
||||
commands_list.append(BotCommand(command, locale(command, "commands", locale=configGet("locale_fallback"))))
|
||||
app.set_bot_commands(commands_list)
|
||||
await app.set_bot_commands(commands_list)
|
||||
|
||||
# Registering admin commands
|
||||
commands_admin_list = []
|
||||
|
||||
if configGet("submit", "mode"):
|
||||
for command in configGet("commands"):
|
||||
|
||||
commands_admin_list.append(BotCommand(command, locale(command, "commands", locale=configGet("locale"))))
|
||||
for command in configGet("commands_admin"):
|
||||
commands_admin_list.append(BotCommand(command, locale(command, "commands_admin", locale=configGet("locale"))))
|
||||
app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=configGet("admin")))
|
||||
|
||||
await app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=configGet("admin")))
|
Reference in New Issue
Block a user