diff --git a/app.py b/app.py index a30216e..0c1e383 100644 --- a/app.py +++ b/app.py @@ -8,13 +8,19 @@ from pyrogram.errors import bad_request_400 app = Client("holochecker", bot_token=configGet("bot_token", "bot"), api_id=configGet("api_id", "bot"), api_hash=configGet("api_hash", "bot")) async def isAnAdmin(admin_id): + + # Check if user is mentioned in config if (admin_id == configGet("owner")) or (admin_id in configGet("admins")): return True + + # Check if user is probably in cache if path.exists(f"cache{sep}admins") is True: try: return True if admin_id in jsonLoad(f"cache{sep}admins") else False except (FileNotFoundError, JSONDecodeError): pass + + # Check if user is in admin group try: async for member in app.get_chat_members(configGet("admin_group")): if member.user.id == admin_id: @@ -22,4 +28,5 @@ async def isAnAdmin(admin_id): except bad_request_400.ChannelInvalid: logWrite(f"Could not get users in admin group to answer isAnAdmin(). Bot is likely not in the group.") return False + return False \ No newline at end of file diff --git a/modules/custom_filters.py b/modules/custom_filters.py index e840a62..148b01c 100644 --- a/modules/custom_filters.py +++ b/modules/custom_filters.py @@ -4,11 +4,12 @@ usage in context of Holo Users.""" from app import isAnAdmin from modules.database import col_applications from pyrogram import filters +from pyrogram.types import Message -async def admin_func(_, __, msg): - return await isAnAdmin(msg) +async def admin_func(_, __, msg: Message): + return await isAnAdmin(msg.from_user.id) -async def allowed_func(_, __, msg): +async def allowed_func(_, __, msg: Message): return True if (col_applications.find_one({"user": msg.from_user.id}) is not None) else False admin = filters.create(admin_func)