forked from TeamUltroid/Ultroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblacklist.py
83 lines (67 loc) · 2.23 KB
/
blacklist.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Ultroid - UserBot
# Copyright (C) 2021-2022 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
• `{i}blacklist <word/all words with a space>`
blacklist the choosen word in that chat.
• `{i}remblacklist <word>`
Remove the word from blacklist..
• `{i}listblacklist`
list all blacklisted words.
'if a person uses blacklist Word his/her msg will be deleted'
'And u Must be Admin in that Chat'
"""
from pyUltroid.dB.blacklist_db import (
add_blacklist,
get_blacklist,
list_blacklist,
rem_blacklist,
)
from . import events, get_string, udB, ultroid_bot, ultroid_cmd
@ultroid_cmd(pattern="blacklist( (.*)|$)", admins_only=True)
async def af(e):
wrd = e.pattern_match.group(1).strip()
chat = e.chat_id
if not (wrd):
return await e.eor(get_string("blk_1"), time=5)
wrd = e.text[11:]
heh = wrd.split(" ")
for z in heh:
add_blacklist(int(chat), z.lower())
ultroid_bot.add_handler(blacklist, events.NewMessage(incoming=True))
await e.eor(get_string("blk_2").format(wrd))
@ultroid_cmd(pattern="remblacklist( (.*)|$)", admins_only=True)
async def rf(e):
wrd = e.pattern_match.group(1).strip()
chat = e.chat_id
if not wrd:
return await e.eor(get_string("blk_3"), time=5)
wrd = e.text[14:]
heh = wrd.split(" ")
for z in heh:
rem_blacklist(int(chat), z.lower())
await e.eor(get_string("blk_4").format(wrd))
@ultroid_cmd(pattern="listblacklist$", admins_only=True)
async def lsnote(e):
x = list_blacklist(e.chat_id)
if x:
sd = get_string("blk_5")
return await e.eor(sd + x)
await e.eor(get_string("blk_6"))
async def blacklist(e):
x = get_blacklist(e.chat_id)
if x:
for z in e.text.lower().split():
for zz in x:
if z == zz:
try:
await e.delete()
break
except BaseException:
break
if udB.get_key("BLACKLIST_DB"):
ultroid_bot.add_handler(blacklist, events.NewMessage(incoming=True))