diff --git a/config.json b/config.json index 3bb12ba..b4621f7 100644 --- a/config.json +++ b/config.json @@ -76,5 +76,8 @@ "commands": [ "start", "rules" + ], + "commands_admin": [ + "reboot" ] } \ No newline at end of file diff --git a/main.py b/main.py index 85d5e9d..fee58d0 100644 --- a/main.py +++ b/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()