Optimized for DB/OOP

This commit is contained in:
Profitroll 2022-12-16 11:15:56 +01:00
parent b3ec78d54e
commit 57428e530a

View File

@ -2,17 +2,24 @@ from os import sep, path
from app import app, isAnAdmin from app import app, isAnAdmin
from pyrogram.types import ChatPermissions, InlineKeyboardMarkup, InlineKeyboardButton from pyrogram.types import ChatPermissions, InlineKeyboardMarkup, InlineKeyboardButton
from modules.utils import configGet, jsonLoad, locale from modules.utils import configGet, jsonLoad, locale
from modules.database import col_users
from classes.holo_user import HoloUser
# Filter users on join ========================================================================================================= # Filter users on join =========================================================================================================
@app.on_chat_member_updated(group=configGet("destination_group")) @app.on_chat_member_updated(group=configGet("destination_group"))
#@app.on_message(filters.new_chat_members, group=configGet("destination_group")) #@app.on_message(filters.new_chat_members, group=configGet("destination_group"))
async def filter_join(app, member): async def filter_join(app, member):
if member.invite_link != None: if member.invite_link != None:
if (path.exists(f"{configGet('data', 'locations')}{sep}users{sep}{member.from_user.id}.json") and jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{member.from_user.id}.json")["approved"]) or (await isAnAdmin(member.from_user.id) is True):
if configGet("link", file=str(member.from_user.id)) == member.invite_link.invite_link: holo_user = HoloUser(member.from_user)
return
if (holo_user.link is not None) and (holo_user.link == member.invite_link):
return
if await isAnAdmin(member.invite_link.creator.id): if await isAnAdmin(member.invite_link.creator.id):
return return
await app.send_message(configGet("admin_group"), f"User **{member.from_user.first_name}** (`{member.from_user.id}`) joined the chat not with his personal link", reply_markup=InlineKeyboardMarkup( await app.send_message(configGet("admin_group"), f"User **{member.from_user.first_name}** (`{member.from_user.id}`) joined the chat not with his personal link", reply_markup=InlineKeyboardMarkup(
[ [
[ [