-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathplayer.py
531 lines (475 loc) · 21.1 KB
/
player.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
import os
import time
import glob
import json
import logging
import asyncio
import youtube_dl
from pytube import YouTube
from youtube_search import YoutubeSearch
from pytgcalls import PyTgCalls, idle
from pytgcalls import StreamType
from pytgcalls.types import Update
from pytgcalls.types import AudioPiped, AudioVideoPiped
from pytgcalls.types.stream import StreamAudioEnded, StreamVideoEnded
from pytgcalls.types import (
HighQualityAudio,
HighQualityVideo,
LowQualityVideo,
MediumQualityVideo
)
from pyrogram import Client, filters
from pyrogram.raw.base import Update
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery, Message
from helpers.queues import QUEUE, add_to_queue, get_queue, clear_queue, pop_an_item
from helpers.admin_check import *
bot = Client(
"Music Stream Bot",
bot_token = os.environ["BOT_TOKEN"],
api_id = int(os.environ["API_ID"]),
api_hash = os.environ["API_HASH"]
)
client = Client(os.environ["SESSION_NAME"], int(os.environ["API_ID"]), os.environ["API_HASH"])
app = PyTgCalls(client)
OWNER_ID = int(os.environ["OWNER_ID"])
LIVE_CHATS = []
START_TEXT = """
━━━━━━━━━━━━━━━━━━━
**𝙷𝚎𝚕𝚕𝚘**, <b>{}</b> **𝙸'𝚖 𝚂𝚞𝚙𝚎𝚛 𝙵𝚊𝚜𝚝 𝙼𝚞𝚜𝚒𝚌 𝙿𝚕𝚊𝚢𝚎𝚛 𝙱𝚘𝚝 𝙵𝚘𝚛 𝚃𝚎𝚕𝚎𝚐𝚛𝚊𝚖 𝙶𝚛𝚘𝚞𝚙𝚜 𝙰𝚕𝚕𝚘𝚠𝚜 𝚈𝚘𝚞 𝙿𝚕𝚊𝚢 𝙼𝚞𝚜𝚒𝚌 𝙰𝚗𝚍 𝚅𝚒𝚍𝚎𝚘𝚜 𝙾𝚗 𝙶𝚛𝚘𝚞𝚙 𝚃𝚑𝚛𝚘𝚞𝚐𝚑 𝚃𝚑𝚎 𝙽𝚎𝚠 𝚃𝚎𝚕𝚎𝚐𝚛𝚊𝚖 𝚅𝚒𝚍𝚎𝚘 𝙲𝚑𝚊𝚝....**
┏━━━━━━━━━━━━━━━━━┓
┣★ **𝙱𝚊𝚜𝚎𝚍 𝙾𝚗 𝙻𝚊𝚝𝚎𝚜𝚝 𝚅𝚎𝚛𝚜𝚒𝚘𝚗**
┣★ **𝙱𝚎𝚜𝚝 𝙰𝚞𝚍𝚒𝚘 𝚀𝚞𝚊𝚕𝚒𝚝𝚢**
┣★ **𝙵𝚊𝚜𝚝 & 𝙿𝚘𝚠𝚎𝚛𝚏𝚞𝚕 𝙿𝚕𝚊𝚢𝚎𝚛**
┣★ **𝚀𝚞𝚎𝚞𝚎𝚜 𝙰𝚟𝚊𝚒𝚕𝚊𝚋𝚕𝚎**
┣★ **𝙼𝚞𝚕𝚝𝚒 𝙲𝚑𝚊𝚝𝚜 𝚂𝚞𝚙𝚙𝚘𝚛𝚝𝚎𝚍**
┣★ **𝚈𝚃 𝙻𝚒𝚟𝚎 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐 𝚂𝚞𝚙𝚙𝚘𝚛𝚝𝚎𝚍**
┣★ **𝚁𝚎𝚙𝚘𝚛𝚝 𝙱𝚞𝚐𝚜:** @MissCutie_Support
┣★ **𝙿𝚘𝚠𝚎𝚛𝚎𝚍 𝙱𝚢:** @MissCutieBots
┣★**𝙼𝚊𝚗𝚊𝚐𝚎𝚍 𝙱𝚢:** @SAIFALISEW1508
┗━━━━━━━━━━━━━━━━━┛
━━━━━━━━━━━━━━━━━━━
"""
START_BUTTONS = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"♦️ 𝙰𝚍𝚍 𝚈𝚘𝚞𝚛 𝙶𝚛𝚘𝚞𝚙 ♦️",
url="https://t.me/MissCutiePlayerBot?startgroup=true",
)
],
[
InlineKeyboardButton("📝 𝙼𝚞𝚜𝚒𝚌 𝙲𝚘𝚖𝚖𝚊𝚗𝚍𝚜", callback_data="cbcmds"),
InlineKeyboardButton("🇮🇳 𝙼𝚊𝚗𝚊𝚐𝚎𝚛", user_id="1930139488"),
],
[
InlineKeyboardButton(
"🧞♂ 𝚂𝚞𝚙𝚙𝚘𝚛𝚝", url="https://t.me/MissCutie_Support"
),
InlineKeyboardButton(
"🔔 𝚄𝚙𝚍𝚊𝚝𝚎𝚜", url="https://t.me/MissCutieUpdates"
),
],
[
InlineKeyboardButton(
"↫ 𝚂𝚘𝚞𝚛𝚌𝚎 𝙲𝚘𝚍𝚎 ↬", callback_data="repo_callback"
)
],
]
)
BUTTONS = InlineKeyboardMarkup(
[
[
InlineKeyboardButton("⏸", callback_data="pause"),
InlineKeyboardButton("▶️", callback_data="resume"),
InlineKeyboardButton("⏭", callback_data="skip"),
InlineKeyboardButton("⏹", callback_data="stop"),
InlineKeyboardButton("🔇", callback_data="mute"),
InlineKeyboardButton("🔊", callback_data="unmute")
],
[
InlineKeyboardButton("🗑 Close Menu", callback_data="close")
]
]
)
GROUP_BUTTONS = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(text="• 𝚂𝚞𝚙𝚙𝚘𝚛𝚝 •", url="https://t.me/MissCutie_Support"),
InlineKeyboardButton(text="• 𝙲𝚘𝚖𝚖𝚊𝚗𝚍𝚜 •", callback_data="cbcmds")
]
]
)
BACK_BUTTON = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(text="• Close •", callback_data="close"),
InlineKeyboardButton(text="• Support •", url="https://t.me/MissCutie_Support")
]
]
)
async def skip_current_song(chat_id):
if chat_id not in QUEUE:
return 0
chat_queue = get_queue(chat_id)
if len(chat_queue) == 1:
await app.leave_group_call(chat_id)
clear_queue(chat_id)
return 1
else:
title = chat_queue[1][0]
duration = chat_queue[1][1]
link = chat_queue[1][2]
playlink = chat_queue[1][3]
type = chat_queue[1][4]
Q = chat_queue[1][5]
thumb = chat_queue[1][6]
if type == "Audio":
await app.change_stream(
chat_id,
AudioPiped(
playlink,
),
)
elif type == "Video":
if Q == "high":
hm = HighQualityVideo()
elif Q == "low":
hm = LowQualityVideo()
else:
hm = MediumQualityVideo()
await app.change_stream(
chat_id, AudioVideoPiped(playlink, HighQualityAudio(), hm)
)
pop_an_item(chat_id)
await bot.send_photo(chat_id, photo = thumb,
caption = f"▶️ <b>Now playing:</b> [{title}]({link}) | `{type}` \n\n⏳ <b>Duration:</b> {duration}",
reply_markup = BUTTONS)
return [title, link, type, duration, thumb]
async def skip_item(chat_id, lol):
if chat_id not in QUEUE:
return 0
chat_queue = get_queue(chat_id)
try:
x = int(lol)
title = chat_queue[x][0]
chat_queue.pop(x)
return title
except Exception as e:
print(e)
return 0
@app.on_stream_end()
async def on_end_handler(_, update: Update):
if isinstance(update, StreamAudioEnded):
chat_id = update.chat_id
await skip_current_song(chat_id)
@app.on_closed_voice_chat()
async def close_handler(_, chat_id: int):
if chat_id in QUEUE:
clear_queue(chat_id)
async def yt_video(link):
proc = await asyncio.create_subprocess_exec(
"yt-dlp",
"-g",
"-f",
"best[height<=?720][width<=?1280]",
f"{link}",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await proc.communicate()
return (1, stdout.decode().split("\n")[0]) if stdout else (0, stderr.decode())
async def yt_audio(link):
proc = await asyncio.create_subprocess_exec(
"yt-dlp",
"-g",
"-f",
"bestaudio",
f"{link}",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await proc.communicate()
return (1, stdout.decode().split("\n")[0]) if stdout else (0, stderr.decode())
@bot.on_callback_query(filters.regex("cbcmds"))
async def cbcmds(_, query: CallbackQuery):
await query.answer("Commands Menu")
await query.edit_message_text(
"""🇮🇳 𝑯𝒆𝒍𝒍𝒐 » **⚜𝑳𝒊𝒔𝒕 𝑶𝒇 𝑨𝒗𝒂𝒊𝒍𝒂𝒃𝒍𝒆 𝑪𝒐𝒎𝒎𝒂𝒏𝒅𝒔⚜**
» /play (𝚂𝚘𝚗𝚐 𝙽𝚊𝚖𝚎/𝙻𝚒𝚗𝚔) - **𝙿𝚕𝚊𝚢 𝙼𝚞𝚜𝚒𝚌**
» /vplay (𝚟𝚒𝚍𝚎𝚘 𝚗𝚊𝚖𝚎/𝚕𝚒𝚗𝚔) - **𝙿𝚕𝚊𝚢 𝚅𝚒𝚍𝚎𝚘**
» /liveplay (𝚈𝚘𝚞𝚃𝚞𝚋𝚎 𝙻𝚒𝚗𝚔) - **𝙿𝚕𝚊𝚢 𝙻𝚒𝚟𝚎 𝙼𝚞𝚜𝚒𝚌**
» /livestream (𝚈𝚘𝚞𝚃𝚞𝚋𝚎 𝙻𝚒𝚗𝚔) - **𝚂𝚝𝚛𝚎𝚊𝚖 𝙻𝚒𝚟𝚎 𝚅𝚒𝚍𝚎𝚘**
» /pause - **𝙿𝚊𝚞𝚜𝚎 𝚃𝚑𝚎 𝚂𝚘𝚗𝚐**
» /resume - **𝚁𝚎𝚜𝚞𝚖𝚎 𝚃𝚑𝚎 𝚂𝚘𝚗𝚐**
» /skip - **𝚜𝚠𝚒𝚝𝚌𝚑 𝚝𝚘 𝚗𝚎𝚡𝚝 𝚂𝚘𝚗𝚐**
» /end - **𝚂𝚝𝚘𝚙 𝚃𝚑𝚎 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐**
» /join - **𝙸𝚗𝚟𝚒𝚝𝚎 𝙰𝚜𝚜𝚒𝚜𝚝𝚊𝚗𝚝 𝚃𝚘 𝚈𝚘𝚞𝚛 𝙶𝚛𝚘𝚞𝚙**
» /mute - **𝙼𝚞𝚝𝚎 𝚃𝚑𝚎 𝙰𝚜𝚜𝚒𝚜𝚝𝚊𝚗𝚝 𝙾𝚗 𝚅𝚘𝚒𝚌𝚎 𝙲𝚑𝚊𝚝**
» /unmute - **𝚄𝚗𝙼𝚞𝚝𝚎 𝚃𝚑𝚎 𝙰𝚜𝚜𝚒𝚜𝚝𝚊𝚗𝚝 𝙾𝚗 𝚅𝚘𝚒𝚌𝚎 𝙲𝚑𝚊𝚝**
» /playlist - **𝚂𝚑𝚘𝚠 𝚈𝚘𝚞 𝚃𝚑𝚎 𝙿𝚕𝚊𝚢𝚕𝚒𝚜𝚝**
» /restart - **𝚁𝚎𝚜𝚝𝚊𝚛𝚝 𝚃𝚑𝚎 𝙱𝚘𝚝**
⚡ 𝑷𝒐𝒘𝒆𝒓𝒆𝒅 𝑩𝒚: @MissCutieBots""",
reply_markup=BACK_BUTTON,
)
@bot.on_callback_query(filters.regex("repo_callback"))
async def repo_callback(_, CallbackQuery):
return await CallbackQuery.answer(
"𝙽𝚒𝚌𝚎 𝚃𝚛𝚢 𝙼𝚊𝚗 𝙱𝚞𝚝 𝙾𝚗𝚎 𝚃𝚑𝚒𝚗𝚐 𝙰𝚛𝚎 𝚈𝚘𝚞 𝙰 𝙱𝚒𝚝𝚌𝚑 𝚃𝚑𝚎𝚢 𝚆𝚘𝚞𝚕𝚍 𝙾𝚗𝚕𝚢 𝙰𝚜𝚔 𝙼𝚎 𝚃𝚑𝚎 𝙰𝚋𝚘𝚞𝚝 𝚂𝚘𝚞𝚛𝚌𝚎 𝙲𝚘𝚍𝚎😏 ©️MissCutieBots@SAIFALISEW1508", show_alert=True
)
@bot.on_callback_query(filters.regex("close"))
async def close(bot, message):
await message.message.delete()
await message.message.reply_to_message.delete()
@bot.on_message(filters.command("start") & filters.private)
async def start_private(_, message):
msg = START_TEXT.format(message.from_user.mention)
await message.reply_photo(photo="https://te.legra.ph/file/ab6eb4c9785d231233c71.jpg",
caption = msg,
reply_markup = START_BUTTONS)
@bot.on_message(filters.command(["join", "join@MissCutiePlayerBot"]) & filters.group)
async def join_chat(c: Client, m: Message):
chat_id = m.chat.id
try:
invitelink = await c.export_chat_invite_link(chat_id)
if invitelink.startswith("https://t.me/+"):
invitelink = invitelink.replace(
"https://t.me/+", "https://t.me/joinchat/"
)
await client.join_chat(invitelink)
return await client.send_message(chat_id, "✅ 𝙰𝚜𝚜𝚒𝚜𝚝𝚊𝚗𝚝 𝙹𝚘𝚒𝚗𝚎𝚍 𝚃𝚑𝚎 𝙲𝚑𝚊𝚝")
except UserAlreadyParticipant:
return await client.send_message(chat_id, "✅ 𝙰𝚜𝚜𝚒𝚜𝚝𝚊𝚗𝚝 𝙰𝚕𝚛𝚎𝚊𝚍𝚢 𝙸𝚗 𝙲𝚑𝚊𝚝")
@bot.on_message(filters.command("start") & filters.group)
async def start_group(_, message):
await message.reply_photo(photo="https://te.legra.ph/file/c64734caae40345289712.jpg",
caption = f"𝙷𝚎𝚕𝚕𝚘 🚀 {message.from_user.mention} 🥁 𝙼𝚞𝚜𝚒𝚌 𝙱𝚘𝚝 𝙸𝚜 𝙰𝚕𝚒𝚟𝚎🎸.",
reply_markup = GROUP_BUTTONS)
@bot.on_message(filters.command(["play", "vplay"]) & filters.group)
async def video_play(_, message):
await message.delete()
user_id = message.from_user.id
state = message.command[0].lower()
try:
query = message.text.split(None, 1)[1]
except:
return await message.reply_text(f"<b>Usage:</b> <code>/{state} [query]</code>")
chat_id = message.chat.id
if chat_id in LIVE_CHATS:
return await message.reply_text("❗️𝙿𝚕𝚎𝚊𝚜𝚎 𝚂𝚎𝚗𝚍 <code>/stop</code> 𝚃𝚘 𝙴𝚗𝚍 𝙲𝚞𝚛𝚛𝚎𝚗𝚝 𝙻𝚒𝚟𝚎 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐 𝙱𝚎𝚏𝚘𝚛𝚎 𝙿𝚕𝚊𝚢 𝚂𝚘𝚗𝚐𝚜 𝙾𝚛 𝚅𝚒𝚍𝚎𝚘𝚜.")
m = await message.reply_text("🔄 𝙿𝚛𝚘𝚌𝚎𝚜𝚜𝚒𝚗𝚐...")
if state == "play":
damn = AudioPiped
ded = yt_audio
doom = "Audio"
elif state == "vplay":
damn = AudioVideoPiped
ded = yt_video
doom = "Video"
if "low" in query:
Q = "low"
elif "mid" in query:
Q = "mid"
elif "high" in query:
Q = "high"
else:
Q = "0"
try:
results = YoutubeSearch(query, max_results=1).to_dict()
link = f"https://youtube.com{results[0]['url_suffix']}"
thumb = results[0]["thumbnails"][0]
duration = results[0]["duration"]
yt = YouTube(link)
cap = f"▶️ <b>𝙽𝚘𝚠 𝙿𝚕𝚊𝚢𝚒𝚗𝚐:</b> [{yt.title}]({link}) | `{doom}` \n\n⏳ <b>Duration:</b> {duration}"
try:
ydl_opts = {"format": "bestvideo[height<=720]+bestaudio/best[height<=720]"}
ydl = youtube_dl.YoutubeDL(ydl_opts)
info_dict = ydl.extract_info(link, download=False)
p = json.dumps(info_dict)
a = json.loads(p)
playlink = a['formats'][1]['manifest_url']
except:
ice, playlink = await ded(link)
if ice == "0":
return await m.edit("❗️YTDL ERROR !!!")
except Exception as e:
return await m.edit(str(e))
try:
if chat_id in QUEUE:
position = add_to_queue(chat_id, yt.title, duration, link, playlink, doom, Q, thumb)
caps = f"#️⃣ [{yt.title}]({link}) <b>queued at position {position}</b> \n\n⏳ <b>Duration:</b> {duration}"
await message.reply_photo(thumb, caption=caps)
else:
await app.join_group_call(
chat_id,
damn(playlink),
stream_type=StreamType().pulse_stream
)
add_to_queue(chat_id, yt.title, duration, link, playlink, doom, Q, thumb)
await message.reply_photo(thumb, caption=cap, reply_markup=BUTTONS)
await m.delete()
except Exception as e:
return await m.edit(str(e))
@bot.on_message(filters.command(["liveplay", "livestream"]) & filters.group)
@is_admin
async def stream_func(_, message):
await message.delete()
state = message.command[0].lower()
try:
link = message.text.split(None, 1)[1]
except:
return await message.reply_text(f"<b>Usage:</b> <code>/{state} [link]</code>")
chat_id = message.chat.id
if state == "liveplay":
damn = AudioPiped
emj = "🎵"
elif state == "livestream":
damn = AudioVideoPiped
emj = "🎬"
m = await message.reply_text("🔄 Processing...")
try:
if chat_id in QUEUE:
return await m.edit("❗️Please stop the current playback using /stop command first.")
elif chat_id in LIVE_CHATS:
await app.change_stream(
chat_id,
damn(link),
)
await m.edit(
f"{emj} Started streaming: [Link]({link})", disable_web_page_preview=True
)
else:
await app.join_group_call(
chat_id,
damn(link),
stream_type=StreamType().pulse_stream,
)
await m.edit(
f"{emj} Started streaming: [Link]({link})", disable_web_page_preview=True
)
LIVE_CHATS.append(chat_id)
except Exception as e:
return await m.edit(str(e))
@bot.on_message(filters.command("skip") & filters.group)
@is_admin
async def skip(_, message):
await message.delete()
chat_id = message.chat.id
if len(message.command) < 2:
op = await skip_current_song(chat_id)
if op == 0:
await message.reply_text("❗️𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚗 𝚃𝚑𝚎 𝚀𝚞𝚎𝚞𝚎 𝚃𝚘 𝚂𝚔𝚒𝚙.")
elif op == 1:
await message.reply_text("❗️𝙴𝚖𝚙𝚝𝚢 𝚀𝚞𝚎𝚞𝚎, 𝚂𝚝𝚘𝚙𝚙𝚎𝚍 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐.")
else:
skip = message.text.split(None, 1)[1]
out = "🗑 <b>Removed the following song(s) from the queue:</b> \n"
if chat_id in QUEUE:
items = [int(x) for x in skip.split(" ") if x.isdigit()]
items.sort(reverse=True)
for x in items:
if x != 0:
hm = await skip_item(chat_id, x)
if hm != 0:
out = out + "\n" + f"<b>#️⃣ {x}</b> - {hm}"
await message.reply_text(out)
@bot.on_message(filters.command(["playlist", "queue"]) & filters.group)
@is_admin
async def playlist(_, message):
chat_id = message.chat.id
if chat_id in QUEUE:
chat_queue = get_queue(chat_id)
if len(chat_queue) == 1:
await message.delete()
await message.reply_text(
f"▶️ <b>𝙽𝚘𝚠 𝙿𝚕𝚊𝚢𝚒𝚗𝚐:</b> [{chat_queue[0][0]}]({chat_queue[0][2]}) | `{chat_queue[0][4]}`",
disable_web_page_preview=True,
)
else:
out = f"<b>📃 Player queue:</b> \n\n▶️ <b>𝙽𝚘𝚠 𝙿𝚕𝚊𝚢𝚒𝚗𝚐:</b> [{chat_queue[0][0]}]({chat_queue[0][2]}) | `{chat_queue[0][4]}` \n"
l = len(chat_queue)
for x in range(1, l):
title = chat_queue[x][0]
link = chat_queue[x][2]
type = chat_queue[x][4]
out = out + "\n" + f"<b>#️⃣ {x}</b> - [{title}]({link}) | `{type}` \n"
await message.reply_text(out, disable_web_page_preview=True)
else:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
@bot.on_message(filters.command("stop") & filters.group)
@is_admin
async def end(_, message):
await message.delete()
chat_id = message.chat.id
if chat_id in LIVE_CHATS:
await app.leave_group_call(chat_id)
LIVE_CHATS.remove(chat_id)
return await message.reply_text("⏹ 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐 𝚂𝚝𝚘𝚙𝚙𝚎𝚍.")
if chat_id in QUEUE:
await app.leave_group_call(chat_id)
clear_queue(chat_id)
await message.reply_text("⏹ 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐 𝚂𝚝𝚘𝚙𝚙𝚎𝚍.")
else:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
@bot.on_message(filters.command("pause") & filters.group)
@is_admin
async def pause(_, message):
await message.delete()
chat_id = message.chat.id
if chat_id in QUEUE:
try:
await app.pause_stream(chat_id)
await message.reply_text("⏸ 𝙿𝚊𝚞𝚜𝚎𝚍 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐.")
except:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
else:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
@bot.on_message(filters.command("resume") & filters.group)
@is_admin
async def resume(_, message):
await message.delete()
chat_id = message.chat.id
if chat_id in QUEUE:
try:
await app.resume_stream(chat_id)
await message.reply_text("⏸ 𝚁𝚎𝚜𝚞𝚖𝚎𝚍 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐.")
except:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
else:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
@bot.on_message(filters.command("mute") & filters.group)
@is_admin
async def mute(_, message):
await message.delete()
chat_id = message.chat.id
if chat_id in QUEUE:
try:
await app.mute_stream(chat_id)
await message.reply_text("🔇 𝙼𝚞𝚝𝚎𝚍 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐.")
except:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
else:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
@bot.on_message(filters.command("unmute") & filters.group)
@is_admin
async def unmute(_, message):
await message.delete()
chat_id = message.chat.id
if chat_id in QUEUE:
try:
await app.unmute_stream(chat_id)
await message.reply_text("🔊 𝚄𝚗𝚖𝚞𝚝𝚎𝚍 𝚂𝚝𝚛𝚎𝚊𝚖𝚒𝚗𝚐.")
except:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
else:
await message.reply_text("❗𝙽𝚘𝚝𝚑𝚒𝚗𝚐 𝙸𝚜 𝙿𝚕𝚊𝚢𝚒𝚗𝚐.")
@bot.on_message(filters.command("restart"))
async def restart(_, message):
user_id = message.from_user.id
if user_id != OWNER_ID:
return
await message.reply_text("🛠 <i>𝚁𝚎𝚜𝚝𝚊𝚛𝚝𝚒𝚗𝚐 𝚃𝚑𝚎 𝙱𝚘𝚝 𝙿𝚕𝚎𝚊𝚜𝚎 𝚆𝚊𝚒𝚝 ✋🏻 𝙸𝚝'𝚜 𝙼𝚊𝚢 𝚃𝚊𝚔𝚎 𝟺-𝟻 𝙼𝚒𝚗𝚞𝚝𝚎𝚜 🤐...</i>")
os.system(f"kill -9 {os.getpid()} && python3 app.py")
app.start()
bot.run()
idle()