This repository was archived by the owner on Feb 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathfilters.py
More file actions
48 lines (30 loc) · 1.38 KB
/
filters.py
File metadata and controls
48 lines (30 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from decouple import config
from pyrogram import Filters
from dbmodels import Chats, db
from phrases import taco_emoji
from chattools import ensure_username, get_cid
bot_username = ensure_username(config('BOT_USERNAME', default='HeyTacoBot'))
def filter_taco_(_, query): # filter for taco-emoji in message
if query.text is not None:
return taco_emoji in query.text
return False
filter_taco = Filters.create(filter_taco_)
def filter_self_kicked_(_, query): # filter for update, that bot was kicked from chat
if query.left_chat_member is None:
return False
if ensure_username(query.left_chat_member.username).lower() == bot_username.lower():
return True
return False
filter_self_kicked = Filters.create(filter_self_kicked_)
def filter_new_chat_(_, query): # filter for group, that has tacos-field in DB
with db:
return Chats.select().where(Chats.cid == get_cid(query)).exists()
filter_new_chat = Filters.create(filter_new_chat_)
def filter_mention_(_, query): # filter for mention in text message
if query.entities is None:
return False
for entity in query.entities:
if entity.type == 'mention':
return True
return False
filter_mention = Filters.create(filter_mention_)