2022-12-05 19:49:51 +02:00
|
|
|
from app import app, isAnAdmin
|
|
|
|
from pyrogram.types import ChatPermissions, InlineKeyboardMarkup, InlineKeyboardButton
|
2022-12-16 12:29:10 +02:00
|
|
|
from modules.utils import configGet, locale
|
2022-12-16 13:04:57 +02:00
|
|
|
from modules.logging import logWrite
|
2022-12-16 12:15:56 +02:00
|
|
|
from classes.holo_user import HoloUser
|
2022-12-05 19:49:51 +02:00
|
|
|
|
|
|
|
# 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):
|
2022-12-16 12:15:56 +02:00
|
|
|
|
2022-12-05 19:49:51 +02:00
|
|
|
if member.invite_link != None:
|
2022-12-16 12:15:56 +02:00
|
|
|
|
|
|
|
holo_user = HoloUser(member.from_user)
|
|
|
|
|
2022-12-16 13:04:57 +02:00
|
|
|
if (holo_user.link is not None) and (holo_user.link == member.invite_link.invite_link):
|
|
|
|
logWrite(f"User {holo_user.id} joined destination group with correct link {holo_user.link}")
|
2022-12-16 12:15:56 +02:00
|
|
|
return
|
|
|
|
|
2022-12-05 19:49:51 +02:00
|
|
|
if await isAnAdmin(member.invite_link.creator.id):
|
2022-12-16 13:04:57 +02:00
|
|
|
logWrite(f"User {holo_user.id} joined destination group with link {holo_user.link} of an admin {member.invite_link.creator.id}")
|
2022-12-05 19:49:51 +02:00
|
|
|
return
|
2022-12-16 13:04:57 +02:00
|
|
|
|
|
|
|
logWrite(f"User {holo_user.id} joined destination group with stolen/unapproved link {holo_user.link}")
|
|
|
|
|
|
|
|
await app.send_message(configGet("admin_group"), locale("joined_false_link", "message").format(member.from_user.first_name, member.from_user.id), reply_markup=InlineKeyboardMarkup(
|
2022-12-05 19:49:51 +02:00
|
|
|
[
|
|
|
|
[
|
|
|
|
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
|
|
|
|
)
|
|
|
|
)
|
|
|
|
# ==============================================================================================================================
|