dev (#19)
* Config file changes * Commands `/remove`, `/import` and `/export` Co-authored-by: profitroll <vozhd.kk@gmail.com> Co-authored-by: Profitroll <47523801+profitrollgame@users.noreply.github.com> Co-authored-by: Renovate <renovate@git.end-play.xyz> Reviewed-on: #19
This commit is contained in:
@@ -1,23 +1,37 @@
|
||||
from os import listdir
|
||||
from pyrogram.client import Client
|
||||
from classes.poster_client import PosterClient
|
||||
from pyrogram.types import BotCommand, BotCommandScopeChat
|
||||
from modules.utils import configGet, locale
|
||||
|
||||
async def register_commands(app: Client):
|
||||
|
||||
async def register_commands(app: PosterClient) -> None:
|
||||
if configGet("submit", "mode"):
|
||||
# Registering user commands
|
||||
for entry in listdir(configGet("locale", "locations")):
|
||||
if entry.endswith(".json"):
|
||||
commands_list = []
|
||||
for command in configGet("commands"):
|
||||
commands_list.append(BotCommand(command, locale(command, "commands", locale=entry.replace(".json", ""))))
|
||||
await app.set_bot_commands(commands_list, language_code=entry.replace(".json", ""))
|
||||
commands_list.append(
|
||||
BotCommand(
|
||||
command,
|
||||
locale(
|
||||
command, "commands", locale=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"))))
|
||||
commands_list.append(
|
||||
BotCommand(
|
||||
command,
|
||||
locale(command, "commands", locale=configGet("locale_fallback")),
|
||||
)
|
||||
)
|
||||
await app.set_bot_commands(commands_list)
|
||||
|
||||
# Registering admin commands
|
||||
@@ -25,9 +39,19 @@ async def register_commands(app: Client):
|
||||
|
||||
if configGet("submit", "mode"):
|
||||
for command in configGet("commands"):
|
||||
|
||||
commands_admin_list.append(BotCommand(command, locale(command, "commands", locale=configGet("locale"))))
|
||||
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"))))
|
||||
commands_admin_list.append(
|
||||
BotCommand(
|
||||
command, locale(command, "commands_admin", locale=configGet("locale"))
|
||||
)
|
||||
)
|
||||
|
||||
await app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=configGet("admin")))
|
||||
for admin in app.admins:
|
||||
await app.set_bot_commands(
|
||||
commands_admin_list, scope=BotCommandScopeChat(chat_id=admin)
|
||||
)
|
||||
|
Reference in New Issue
Block a user