-
Notifications
You must be signed in to change notification settings - Fork 1
/
channel.py
67 lines (64 loc) · 2.37 KB
/
channel.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
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.utils.database import set_cmode
from AnonX.utils.decorators.admins import AdminActual
from strings.filters import command
### Multi-Lang Commands
CHANNELPLAY_COMMAND = get_command("CHANNELPLAY_COMMAND")
@app.on_message(
command(CHANNELPLAY_COMMAND)
& filters.group
& ~BANNED_USERS
)
@AdminActual
async def playmode_(client, message: Message, _):
if len(message.command) < 2:
return await message.reply_text(
_["cplay_1"].format(
message.chat.title, CHANNELPLAY_COMMAND[0]
)
)
query = message.text.split(None, 2)[1].lower().strip()
if (str(query)).lower() == "disable":
await set_cmode(message.chat.id, None)
return await message.reply_text(f"ᴄʜᴀɴɴᴇʟ ᴩʟᴀʏ ᴅɪsᴀʙʟᴇᴅ sᴜᴄᴄᴇssғᴜʟʟʏ ʙʏ {message.from_user.first_name} ɪɴ {message.chat.title}")
elif str(query) == "linked":
chat = await app.get_chat(message.chat.id)
if chat.linked_chat:
chat_id = chat.linked_chat.id
await set_cmode(message.chat.id, chat_id)
return await message.reply_text(
_["cplay_3"].format(
chat.linked_chat.title, chat.linked_chat.id
)
)
else:
return await message.reply_text(_["cplay_2"])
else:
try:
chat = await app.get_chat(query)
except:
return await message.reply_text(_["cplay_4"])
if chat.type != "channel":
return await message.reply_text(_["cplay_5"])
try:
admins = await app.get_chat_members(
chat.id, filter="administrators"
)
except:
return await message.reply_text(_["cplay_4"])
for users in admins:
if users.status == "creator":
creatorusername = users.user.username
creatorid = users.user.id
if creatorid != message.from_user.id:
return await message.reply_text(
_["cplay_6"].format(chat.title, creatorusername)
)
await set_cmode(message.chat.id, chat.id)
return await message.reply_text(
_["cplay_3"].format(chat.title, chat.id)
)