Spoilers, major command system improvements #4
@ -105,6 +105,7 @@ async def commands_register():
|
||||
commands = {
|
||||
"users": [],
|
||||
"admins": [],
|
||||
"owner": [],
|
||||
"group_users": [],
|
||||
"group_admins": [],
|
||||
"locales": {}
|
||||
@ -113,6 +114,7 @@ async def commands_register():
|
||||
commands_raw = {
|
||||
"users": [],
|
||||
"admins": [],
|
||||
"owner": [],
|
||||
"group_users": [],
|
||||
"group_admins": [],
|
||||
"locales": {}
|
||||
@ -127,6 +129,7 @@ async def commands_register():
|
||||
commands["locales"][".".join(entry.split(".")[:-1])] = {
|
||||
"users": [],
|
||||
"admins": [],
|
||||
"owner": [],
|
||||
"group_users": [],
|
||||
"group_admins": []
|
||||
}
|
||||
@ -134,6 +137,7 @@ async def commands_register():
|
||||
commands_raw["locales"][".".join(entry.split(".")[:-1])] = {
|
||||
"users": [],
|
||||
"admins": [],
|
||||
"owner": [],
|
||||
"group_users": [],
|
||||
"group_admins": []
|
||||
}
|
||||
@ -181,17 +185,23 @@ async def commands_register():
|
||||
await app.set_bot_commands(commands["locales"][lc]["users"], language_code=lc)
|
||||
logWrite(f"Registered user commands for locale {lc}")
|
||||
|
||||
# Registering admin/owner commands
|
||||
for admin in configGet("admins").extend([configGet("owner")]):
|
||||
# Registering admin commands
|
||||
for admin in configGet("admins"):
|
||||
try:
|
||||
await app.set_bot_commands(commands["admins"].extend(commands["users"]), scope=BotCommandScopeChat(chat_id=admin))
|
||||
if admin == configGet("owner"):
|
||||
logWrite(f"Registered admin commands for owner {configGet('owner')}")
|
||||
else:
|
||||
await app.set_bot_commands(commands["admins"]+commands["users"], scope=BotCommandScopeChat(chat_id=admin))
|
||||
logWrite(f"Registered admin commands for admin {admin}")
|
||||
except bad_request_400.PeerIdInvalid:
|
||||
pass
|
||||
|
||||
# Registering owner commands
|
||||
try:
|
||||
await app.set_bot_commands(commands["admins"]+commands["owner"]+commands["users"], scope=BotCommandScopeChat(chat_id=configGet("owner")))
|
||||
for lc in valid_locales:
|
||||
await app.set_bot_commands(commands["locales"][lc]["admins"]+commands["locales"][lc]["owner"]+commands["locales"][lc]["users"], scope=BotCommandScopeChat(chat_id=configGet("owner")))
|
||||
logWrite(f"Registered admin commands for owner {configGet('owner')}")
|
||||
except bad_request_400.PeerIdInvalid:
|
||||
pass
|
||||
|
||||
# Registering admin group commands
|
||||
try:
|
||||
await app.set_bot_commands(commands["group_admins"], scope=BotCommandScopeChat(chat_id=configGet("admin", "groups")))
|
||||
|
Reference in New Issue
Block a user