/cancel, /identify, sponsorships improvements and fixes #3

Merged
profitroll merged 19 commits from dev into master 2023-01-03 16:45:20 +02:00
2 changed files with 11 additions and 3 deletions
Showing only changes of commit c8f89a7447 - Show all commits

7
app.py
View File

@ -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")) 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): async def isAnAdmin(admin_id):
# Check if user is mentioned in config
if (admin_id == configGet("owner")) or (admin_id in configGet("admins")): if (admin_id == configGet("owner")) or (admin_id in configGet("admins")):
return True return True
# Check if user is probably in cache
if path.exists(f"cache{sep}admins") is True: if path.exists(f"cache{sep}admins") is True:
try: try:
return True if admin_id in jsonLoad(f"cache{sep}admins") else False return True if admin_id in jsonLoad(f"cache{sep}admins") else False
except (FileNotFoundError, JSONDecodeError): except (FileNotFoundError, JSONDecodeError):
pass pass
# Check if user is in admin group
try: try:
async for member in app.get_chat_members(configGet("admin_group")): async for member in app.get_chat_members(configGet("admin_group")):
if member.user.id == admin_id: if member.user.id == admin_id:
@ -22,4 +28,5 @@ async def isAnAdmin(admin_id):
except bad_request_400.ChannelInvalid: except bad_request_400.ChannelInvalid:
logWrite(f"Could not get users in admin group to answer isAnAdmin(). Bot is likely not in the group.") logWrite(f"Could not get users in admin group to answer isAnAdmin(). Bot is likely not in the group.")
return False return False
return False return False

View File

@ -4,11 +4,12 @@ usage in context of Holo Users."""
from app import isAnAdmin from app import isAnAdmin
from modules.database import col_applications from modules.database import col_applications
from pyrogram import filters from pyrogram import filters
from pyrogram.types import Message
async def admin_func(_, __, msg): async def admin_func(_, __, msg: Message):
return await isAnAdmin(msg) 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 return True if (col_applications.find_one({"user": msg.from_user.id}) is not None) else False
admin = filters.create(admin_func) admin = filters.create(admin_func)