From 2e8277d6d2d94bbd914a4de21a4f97ee15074aa1 Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 5 Jan 2023 12:42:15 +0100 Subject: [PATCH] Added "owner" as an additional command permission --- modules/scheduled.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/modules/scheduled.py b/modules/scheduled.py index 4ded913..47116da 100644 --- a/modules/scheduled.py +++ b/modules/scheduled.py @@ -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: - logWrite(f"Registered admin commands for admin {admin}") + 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")))