Added "group_users_admins" command scope

This commit is contained in:
Profitroll 2023-01-09 13:08:02 +01:00
parent eced1b7984
commit 64b0562bc4
2 changed files with 15 additions and 5 deletions

View File

@ -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"

View File

@ -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)