forked from sultansq/kiu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blacklistchat.py
77 lines (69 loc) · 2.38 KB
/
blacklistchat.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
from pyrogram import filters
from pyrogram.types import Message
from config import BANNED_USERS
from strings import get_command
from AnonX import app
from AnonX.misc import SUDOERS
from AnonX.utils.database import (blacklist_chat,
blacklisted_chats,
whitelist_chat)
from AnonX.utils.decorators.language import language
from strings.filters import command
# Commands
BLACKLISTCHAT_COMMAND = get_command("BLACKLISTCHAT_COMMAND")
WHITELISTCHAT_COMMAND = get_command("WHITELISTCHAT_COMMAND")
BLACKLISTEDCHAT_COMMAND = get_command("BLACKLISTEDCHAT_COMMAND")
@app.on_message(
command(BLACKLISTCHAT_COMMAND)
& SUDOERS
)
@language
async def blacklist_chat_func(client, message: Message, _):
if len(message.command) != 2:
return await message.reply_text(_["black_1"])
chat_id = int(message.text.strip().split()[1])
if chat_id in await blacklisted_chats():
return await message.reply_text(_["black_2"])
blacklisted = await blacklist_chat(chat_id)
if blacklisted:
await message.reply_text(_["black_3"])
else:
await message.reply_text("sᴏᴍᴇᴛʜɪɴɢ ᴡᴇɴᴛ ᴡʀᴏɴɢ.")
try:
await app.leave_chat(chat_id)
except:
pass
@app.on_message(
command(WHITELISTCHAT_COMMAND)
& SUDOERS
)
@language
async def white_funciton(client, message: Message, _):
if len(message.command) != 2:
return await message.reply_text(_["black_4"])
chat_id = int(message.text.strip().split()[1])
if chat_id not in await blacklisted_chats():
return await message.reply_text(_["black_5"])
whitelisted = await whitelist_chat(chat_id)
if whitelisted:
return await message.reply_text(_["black_6"])
await message.reply_text("sᴏᴍᴇᴛʜɪɴɢ ᴡᴇɴᴛ ᴡʀᴏɴɢ.")
@app.on_message(
command(BLACKLISTEDCHAT_COMMAND)
& ~BANNED_USERS
)
@language
async def all_chats(client, message: Message, _):
text = _["black_7"]
j = 0
for count, chat_id in enumerate(await blacklisted_chats(), 1):
try:
title = (await app.get_chat(chat_id)).title
except Exception:
title = "ᴩʀɪᴠᴀᴛᴇ ᴄʜᴀᴛ"
j = 1
text += f"**{count}. {title}** [`{chat_id}`]\n"
if j == 0:
await message.reply_text(_["black_8"])
else:
await message.reply_text(text)