forked from TeamUltroid/Ultroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanaction.py
58 lines (46 loc) · 1.49 KB
/
cleanaction.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
# 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}addclean`
Clean all Upcoming action msg in added chat like someone joined/left/pin etc.
•`{i}remclean`
Remove chat from database.
•`{i}listclean`
To get list of all chats where its activated.
"""
from telethon.utils import get_display_name
from . import get_string, udB, ultroid_cmd
@ultroid_cmd(pattern="addclean$", admins_only=True)
async def _(e):
key = udB.get_key("CLEANCHAT") or []
if e.chat_id in key:
return await eod(e, get_string("clan_5"))
key.append(e.chat_id)
udB.set_key("CLEANCHAT", key)
await e.eor(get_string("clan_1"), time=5)
@ultroid_cmd(pattern="remclean$")
async def _(e):
key = udB.get_key("CLEANCHAT") or []
if e.chat_id in key:
key.remove(e.chat_id)
udB.set_key("CLEANCHAT", key)
await e.eor(get_string("clan_2"), time=5)
@ultroid_cmd(pattern="listclean$")
async def _(e):
k = udB.get_key("CLEANCHAT")
if k:
o = ""
for x in k:
try:
title = get_display_name(await e.client.get_entity(x))
except BaseException:
title = get_string("clan_3")
o += f"{x} {title}\n"
await e.eor(o)
else:
await e.eor(get_string("clan_4"), time=5)