Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions plugins/pm_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
BUTTONS = {}


@Client.on_message(filters.group & filters.text)
@Client.on_message(filters.group & filters.text & filters.private)
async def give_filter(client,message):
group_id = message.chat.id
name = message.text
user_id = message.chat.id

keywords = await get_filters(group_id)
keywords = await get_filters(group_id, user_id)
for keyword in reversed(sorted(keywords, key=len)):
pattern = r"( |^|[^\w])" + re.escape(keyword) + r"( |$|[^\w])"
if re.search(pattern, name, flags=re.IGNORECASE):
reply_text, btn, alert, fileid = await find_filter(group_id, keyword)
reply_text, btn, alert, fileid = await find_filter(group_id, user_id, keyword)

if reply_text:
reply_text = reply_text.replace("\\n", "\n").replace("\\t", "\t")
Expand Down