From 64b0562bc412c45e78466f386805e8b888983e42 Mon Sep 17 00:00:00 2001 From: profitroll Date: Mon, 9 Jan 2023 13:08:02 +0100 Subject: [PATCH] Added "group_users_admins" command scope --- config_example.json | 3 +-- modules/scheduled.py | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/config_example.json b/config_example.json index 5080175..5d06ffc 100644 --- a/config_example.json +++ b/config_example.json @@ -114,7 +114,6 @@ "permissions": [ "users", "admins", - "group_users", "group_admins" ], "modules": [ @@ -123,7 +122,7 @@ }, "warn": { "permissions": [ - "group_users" + "group_users_admins" ], "modules": [ "warnings" diff --git a/modules/scheduled.py b/modules/scheduled.py index bd0d0d0..13a7322 100644 --- a/modules/scheduled.py +++ b/modules/scheduled.py @@ -6,7 +6,7 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler from datetime import datetime, timedelta from ujson import dumps from app import app -from pyrogram.types import BotCommand, BotCommandScopeChat +from pyrogram.types import BotCommand, BotCommandScopeChat, BotCommandScopeChatAdministrators from pyrogram.errors import bad_request_400 from pyrogram.enums.chat_members_filter import ChatMembersFilter from classes.holo_user import HoloUser @@ -110,6 +110,7 @@ async def commands_register(): "owner": [], "group_users": [], "group_admins": [], + "group_users_admins": [], "locales": {} } @@ -119,6 +120,7 @@ async def commands_register(): "owner": [], "group_users": [], "group_admins": [], + "group_users_admins": [], "locales": {} } @@ -133,7 +135,8 @@ async def commands_register(): "admins": [], "owner": [], "group_users": [], - "group_admins": [] + "group_admins": [], + "group_users_admins": [] } if configGet("debug") is True: commands_raw["locales"][".".join(entry.split(".")[:-1])] = { @@ -141,7 +144,8 @@ async def commands_register(): "admins": [], "owner": [], "group_users": [], - "group_admins": [] + "group_admins": [], + "group_users_admins": [] } config_modules = configGet("features") @@ -217,6 +221,13 @@ async def commands_register(): except bad_request_400.ChannelInvalid: logWrite(f"Could not register commands for destination group. Bot is likely not in the group.") + # Registering destination group admin commands + try: + await app.set_bot_commands(commands["group_users_admins"], scope=BotCommandScopeChatAdministrators(chat_id=configGet("users", "groups"))) + logWrite("Registered destination group admin commands") + except bad_request_400.ChannelInvalid: + logWrite(f"Could not register admin commands for destination group. Bot is likely not in the group.") + if configGet("debug") is True: print(commands, flush=True)