2022-12-05 19:49:51 +02:00
from os import sep , path
from app import app , isAnAdmin
from pyrogram . types import ChatPermissions , InlineKeyboardMarkup , InlineKeyboardButton
from modules . utils import configGet , jsonLoad , locale
# Filter users on join =========================================================================================================
@app.on_chat_member_updated ( group = configGet ( " destination_group " ) )
#@app.on_message(filters.new_chat_members, group=configGet("destination_group"))
async def filter_join ( app , member ) :
if member . invite_link != None :
2022-12-15 15:31:42 +02:00
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 ) :
2022-12-05 19:49:51 +02:00
if configGet ( " link " , file = str ( member . from_user . id ) ) == member . invite_link . invite_link :
return
if await isAnAdmin ( member . invite_link . creator . id ) :
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 (
[
[
InlineKeyboardButton ( text = str ( locale ( " sus_allow " , " button " ) ) , callback_data = f " sus_allow_ { member . from_user . id } " )
] ,
[
2022-12-15 14:50:11 +02:00
InlineKeyboardButton ( text = str ( locale ( " sus_reject " , " button " ) ) , callback_data = f " sus_reject_ { member . from_user . id } " )
2022-12-05 19:49:51 +02:00
]
]
) )
await app . restrict_chat_member ( member . chat . id , member . from_user . id , permissions = ChatPermissions (
can_send_messages = False ,
can_send_media_messages = False ,
can_send_other_messages = False ,
can_send_polls = False
)
)
# ==============================================================================================================================