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