abhay2245 commited on
Commit
58afac5
Β·
verified Β·
1 Parent(s): 4333982

Create plugins/blacklist.py

Browse files
Files changed (1) hide show
  1. plugins/blacklist.py +69 -0
plugins/blacklist.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2021-2025 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from . import get_help
9
+
10
+ __doc__ = get_help("help_blacklist")
11
+
12
+
13
+ from pyUltroid.dB.blacklist_db import (
14
+ add_blacklist,
15
+ get_blacklist,
16
+ list_blacklist,
17
+ rem_blacklist,
18
+ )
19
+
20
+ from . import events, get_string, udB, ultroid_bot, ultroid_cmd
21
+
22
+
23
+ @ultroid_cmd(pattern="blacklist( (.*)|$)", admins_only=True)
24
+ async def af(e):
25
+ wrd = e.pattern_match.group(1).strip()
26
+ chat = e.chat_id
27
+ if not (wrd):
28
+ return await e.eor(get_string("blk_1"), time=5)
29
+ wrd = e.text[11:]
30
+ heh = wrd.split(" ")
31
+ for z in heh:
32
+ add_blacklist(int(chat), z.lower())
33
+ ultroid_bot.add_handler(blacklist, events.NewMessage(incoming=True))
34
+ await e.eor(get_string("blk_2").format(wrd))
35
+
36
+
37
+ @ultroid_cmd(pattern="remblacklist( (.*)|$)", admins_only=True)
38
+ async def rf(e):
39
+ wrd = e.pattern_match.group(1).strip()
40
+ chat = e.chat_id
41
+ if not wrd:
42
+ return await e.eor(get_string("blk_3"), time=5)
43
+ wrd = e.text[14:]
44
+ heh = wrd.split(" ")
45
+ for z in heh:
46
+ rem_blacklist(int(chat), z.lower())
47
+ await e.eor(get_string("blk_4").format(wrd))
48
+
49
+
50
+ @ultroid_cmd(pattern="listblacklist$", admins_only=True)
51
+ async def lsnote(e):
52
+ if x := list_blacklist(e.chat_id):
53
+ sd = get_string("blk_5")
54
+ return await e.eor(sd + x)
55
+ await e.eor(get_string("blk_6"))
56
+
57
+
58
+ async def blacklist(e):
59
+ if x := get_blacklist(e.chat_id):
60
+ text = e.text.lower().split()
61
+ if any((z in text) for z in x):
62
+ try:
63
+ await e.delete()
64
+ except BaseException:
65
+ pass
66
+
67
+
68
+ if udB.get_key("BLACKLIST_DB"):
69
+ ultroid_bot.add_handler(blacklist, events.NewMessage(incoming=True))