Improved filtering
This commit is contained in:
parent
bbcbd3142c
commit
3335dcb326
20
main.py
20
main.py
@ -6,7 +6,7 @@ from modules.utils import *
|
||||
from pyrogram.client import Client
|
||||
from pyrogram import filters
|
||||
from pyrogram.enums.parse_mode import ParseMode
|
||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, BotCommand, BotCommandScopeChat, ReplyKeyboardMarkup, ForceReply, ReplyKeyboardRemove
|
||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, BotCommand, BotCommandScopeChat, ReplyKeyboardMarkup, ForceReply, ReplyKeyboardRemove, ChatPermissions
|
||||
from pyrogram import idle # type: ignore
|
||||
from pyrogram.errors.exceptions import bad_request_400
|
||||
|
||||
@ -330,7 +330,23 @@ async def any_stage(app, msg):
|
||||
# Filter users on join =========================================================================================================
|
||||
@app.on_chat_member_updated(filters.new_chat_members, group=configGet("destination_group"))
|
||||
async def filter_join(app, member):
|
||||
pass # Check if invite link belongs to this user
|
||||
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 (member.from_user.id in configGet("admins")) or (member.from_user.id == configGet("owner")):
|
||||
if configGet("link", file=str(member.from_user.id)) == member.invite_link.invite_link:
|
||||
return
|
||||
await app.send_message(reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(text="Allow usage", callback_data=f"sus_allow_{member.from_user.id}")
|
||||
]
|
||||
]
|
||||
))
|
||||
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
|
||||
)
|
||||
)
|
||||
# ==============================================================================================================================
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user