Admin now also gets user commands
This commit is contained in:
parent
d4a2145036
commit
2591d26349
@ -76,5 +76,8 @@
|
||||
"commands": [
|
||||
"start",
|
||||
"rules"
|
||||
],
|
||||
"commands_admin": [
|
||||
"reboot"
|
||||
]
|
||||
}
|
13
main.py
13
main.py
@ -369,6 +369,7 @@ if __name__ == "__main__":
|
||||
t = Thread(target=background_task)
|
||||
t.start()
|
||||
|
||||
# Registering user commands
|
||||
for entry in os.listdir(configGet("locale", "locations")):
|
||||
if entry.endswith(".json"):
|
||||
commands_list = []
|
||||
@ -376,15 +377,19 @@ if __name__ == "__main__":
|
||||
commands_list.append(BotCommand(command, locale(command, "commands", locale=entry.replace(".json", ""))))
|
||||
app.set_bot_commands(commands_list, language_code=entry.replace(".json", "")) # type: ignore
|
||||
|
||||
# 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) # type: ignore
|
||||
|
||||
app.set_bot_commands([ # type: ignore
|
||||
BotCommand("reboot", locale("reboot", "commands_admin", locale=configGet("locale"))),
|
||||
],
|
||||
scope=BotCommandScopeChat(chat_id=configGet("admin")))
|
||||
# Registering admin commands
|
||||
commands_admin_list = []
|
||||
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"))) # type: ignore
|
||||
|
||||
idle()
|
||||
|
||||
|
Reference in New Issue
Block a user