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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
import string
|
3 |
+
|
4 |
+
from pyrogram import filters
|
5 |
+
from pyrogram.types import InlineKeyboardMarkup, InputMediaPhoto, Message
|
6 |
+
from pytgcalls.exceptions import NoActiveGroupCall
|
7 |
+
|
8 |
+
import config
|
9 |
+
from DragMusic import Apple, Resso, SoundCloud, Spotify, Telegram, YouTube, app
|
10 |
+
from DragMusic.core.call import Drag
|
11 |
+
from DragMusic.utils import seconds_to_min, time_to_seconds
|
12 |
+
from DragMusic.utils.channelplay import get_channeplayCB
|
13 |
+
from DragMusic.utils.decorators.language import languageCB
|
14 |
+
from DragMusic.utils.decorators.play import PlayWrapper
|
15 |
+
from DragMusic.utils.formatters import formats
|
16 |
+
from DragMusic.utils.inline import (
|
17 |
+
botplaylist_markup,
|
18 |
+
livestream_markup,
|
19 |
+
playlist_markup,
|
20 |
+
slider_markup,
|
21 |
+
track_markup,
|
22 |
+
)
|
23 |
+
from DragMusic.utils.logger import play_logs
|
24 |
+
from DragMusic.utils.stream.stream import stream
|
25 |
+
from config import BANNED_USERS, lyrical
|
26 |
+
|
27 |
+
|
28 |
+
@app.on_message(
|
29 |
+
filters.command(
|
30 |
+
[
|
31 |
+
"play",
|
32 |
+
"vplay",
|
33 |
+
"cplay",
|
34 |
+
"cvplay",
|
35 |
+
"playforce",
|
36 |
+
"vplayforce",
|
37 |
+
"cplayforce",
|
38 |
+
"cvplayforce",
|
39 |
+
]
|
40 |
+
)
|
41 |
+
& filters.group
|
42 |
+
& ~BANNED_USERS
|
43 |
+
)
|
44 |
+
@PlayWrapper
|
45 |
+
async def play_commnd(
|
46 |
+
client,
|
47 |
+
message: Message,
|
48 |
+
_,
|
49 |
+
chat_id,
|
50 |
+
video,
|
51 |
+
channel,
|
52 |
+
playmode,
|
53 |
+
url,
|
54 |
+
fplay,
|
55 |
+
):
|
56 |
+
mystic = await message.reply_text(
|
57 |
+
_["play_2"].format(channel) if channel else _["play_1"]
|
58 |
+
)
|
59 |
+
plist_id = None
|
60 |
+
slider = None
|
61 |
+
plist_type = None
|
62 |
+
spotify = None
|
63 |
+
user_id = message.from_user.id
|
64 |
+
user_name = message.from_user.first_name
|
65 |
+
audio_telegram = (
|
66 |
+
(message.reply_to_message.audio or message.reply_to_message.voice)
|
67 |
+
if message.reply_to_message
|
68 |
+
else None
|
69 |
+
)
|
70 |
+
video_telegram = (
|
71 |
+
(message.reply_to_message.video or message.reply_to_message.document)
|
72 |
+
if message.reply_to_message
|
73 |
+
else None
|
74 |
+
)
|
75 |
+
if audio_telegram:
|
76 |
+
if audio_telegram.file_size > 104857600:
|
77 |
+
return await mystic.edit_text(_["play_5"])
|
78 |
+
duration_min = seconds_to_min(audio_telegram.duration)
|
79 |
+
if (audio_telegram.duration) > config.DURATION_LIMIT:
|
80 |
+
return await mystic.edit_text(
|
81 |
+
_["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
|
82 |
+
)
|
83 |
+
file_path = await Telegram.get_filepath(audio=audio_telegram)
|
84 |
+
if await Telegram.download(_, message, mystic, file_path):
|
85 |
+
message_link = await Telegram.get_link(message)
|
86 |
+
file_name = await Telegram.get_filename(audio_telegram, audio=True)
|
87 |
+
dur = await Telegram.get_duration(audio_telegram, file_path)
|
88 |
+
details = {
|
89 |
+
"title": file_name,
|
90 |
+
"link": message_link,
|
91 |
+
"path": file_path,
|
92 |
+
"dur": dur,
|
93 |
+
}
|
94 |
+
|
95 |
+
try:
|
96 |
+
await stream(
|
97 |
+
_,
|
98 |
+
mystic,
|
99 |
+
user_id,
|
100 |
+
details,
|
101 |
+
chat_id,
|
102 |
+
user_name,
|
103 |
+
message.chat.id,
|
104 |
+
streamtype="telegram",
|
105 |
+
forceplay=fplay,
|
106 |
+
)
|
107 |
+
except Exception as e:
|
108 |
+
print(f"Error: {e}")
|
109 |
+
ex_type = type(e).__name__
|
110 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
111 |
+
return await mystic.edit_text(err)
|
112 |
+
return await mystic.delete()
|
113 |
+
return
|
114 |
+
elif video_telegram:
|
115 |
+
if message.reply_to_message.document:
|
116 |
+
try:
|
117 |
+
ext = video_telegram.file_name.split(".")[-1]
|
118 |
+
if ext.lower() not in formats:
|
119 |
+
return await mystic.edit_text(
|
120 |
+
_["play_7"].format(f"{' | '.join(formats)}")
|
121 |
+
)
|
122 |
+
except:
|
123 |
+
return await mystic.edit_text(
|
124 |
+
_["play_7"].format(f"{' | '.join(formats)}")
|
125 |
+
)
|
126 |
+
if video_telegram.file_size > config.TG_VIDEO_FILESIZE_LIMIT:
|
127 |
+
return await mystic.edit_text(_["play_8"])
|
128 |
+
file_path = await Telegram.get_filepath(video=video_telegram)
|
129 |
+
if await Telegram.download(_, message, mystic, file_path):
|
130 |
+
message_link = await Telegram.get_link(message)
|
131 |
+
file_name = await Telegram.get_filename(video_telegram)
|
132 |
+
dur = await Telegram.get_duration(video_telegram, file_path)
|
133 |
+
details = {
|
134 |
+
"title": file_name,
|
135 |
+
"link": message_link,
|
136 |
+
"path": file_path,
|
137 |
+
"dur": dur,
|
138 |
+
}
|
139 |
+
try:
|
140 |
+
await stream(
|
141 |
+
_,
|
142 |
+
mystic,
|
143 |
+
user_id,
|
144 |
+
details,
|
145 |
+
chat_id,
|
146 |
+
user_name,
|
147 |
+
message.chat.id,
|
148 |
+
video=True,
|
149 |
+
streamtype="telegram",
|
150 |
+
forceplay=fplay,
|
151 |
+
)
|
152 |
+
except Exception as e:
|
153 |
+
print(f"Error: {e}")
|
154 |
+
ex_type = type(e).__name__
|
155 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
156 |
+
return await mystic.edit_text(err)
|
157 |
+
return await mystic.delete()
|
158 |
+
return
|
159 |
+
elif url:
|
160 |
+
if await YouTube.exists(url):
|
161 |
+
if "playlist" in url:
|
162 |
+
try:
|
163 |
+
details = await YouTube.playlist(
|
164 |
+
url,
|
165 |
+
config.PLAYLIST_FETCH_LIMIT,
|
166 |
+
message.from_user.id,
|
167 |
+
)
|
168 |
+
except:
|
169 |
+
return await mystic.edit_text(_["play_3"])
|
170 |
+
streamtype = "playlist"
|
171 |
+
plist_type = "yt"
|
172 |
+
if "&" in url:
|
173 |
+
plist_id = (url.split("=")[1]).split("&")[0]
|
174 |
+
else:
|
175 |
+
plist_id = url.split("=")[1]
|
176 |
+
img = config.PLAYLIST_IMG_URL
|
177 |
+
cap = _["play_9"]
|
178 |
+
else:
|
179 |
+
try:
|
180 |
+
details, track_id = await YouTube.track(url)
|
181 |
+
except:
|
182 |
+
return await mystic.edit_text(_["play_3"])
|
183 |
+
streamtype = "youtube"
|
184 |
+
img = details["thumb"]
|
185 |
+
cap = _["play_10"].format(
|
186 |
+
details["title"],
|
187 |
+
details["duration_min"],
|
188 |
+
)
|
189 |
+
elif await Spotify.valid(url):
|
190 |
+
spotify = True
|
191 |
+
if not config.SPOTIFY_CLIENT_ID and not config.SPOTIFY_CLIENT_SECRET:
|
192 |
+
return await mystic.edit_text(
|
193 |
+
"» sᴘᴏᴛɪғʏ ɪs ɴᴏᴛ sᴜᴘᴘᴏʀᴛᴇᴅ ʏᴇᴛ.\n\nᴘʟᴇᴀsᴇ ᴛʀʏ ᴀɢᴀɪɴ ʟᴀᴛᴇʀ."
|
194 |
+
)
|
195 |
+
if "track" in url:
|
196 |
+
try:
|
197 |
+
details, track_id = await Spotify.track(url)
|
198 |
+
except:
|
199 |
+
return await mystic.edit_text(_["play_3"])
|
200 |
+
streamtype = "youtube"
|
201 |
+
img = details["thumb"]
|
202 |
+
cap = _["play_10"].format(details["title"], details["duration_min"])
|
203 |
+
elif "playlist" in url:
|
204 |
+
try:
|
205 |
+
details, plist_id = await Spotify.playlist(url)
|
206 |
+
except Exception:
|
207 |
+
return await mystic.edit_text(_["play_3"])
|
208 |
+
streamtype = "playlist"
|
209 |
+
plist_type = "spplay"
|
210 |
+
img = config.SPOTIFY_PLAYLIST_IMG_URL
|
211 |
+
cap = _["play_11"].format(app.mention, message.from_user.mention)
|
212 |
+
elif "album" in url:
|
213 |
+
try:
|
214 |
+
details, plist_id = await Spotify.album(url)
|
215 |
+
except:
|
216 |
+
return await mystic.edit_text(_["play_3"])
|
217 |
+
streamtype = "playlist"
|
218 |
+
plist_type = "spalbum"
|
219 |
+
img = config.SPOTIFY_ALBUM_IMG_URL
|
220 |
+
cap = _["play_11"].format(app.mention, message.from_user.mention)
|
221 |
+
elif "artist" in url:
|
222 |
+
try:
|
223 |
+
details, plist_id = await Spotify.artist(url)
|
224 |
+
except:
|
225 |
+
return await mystic.edit_text(_["play_3"])
|
226 |
+
streamtype = "playlist"
|
227 |
+
plist_type = "spartist"
|
228 |
+
img = config.SPOTIFY_ARTIST_IMG_URL
|
229 |
+
cap = _["play_11"].format(message.from_user.first_name)
|
230 |
+
else:
|
231 |
+
return await mystic.edit_text(_["play_15"])
|
232 |
+
elif await Apple.valid(url):
|
233 |
+
if "album" in url:
|
234 |
+
try:
|
235 |
+
details, track_id = await Apple.track(url)
|
236 |
+
except:
|
237 |
+
return await mystic.edit_text(_["play_3"])
|
238 |
+
streamtype = "youtube"
|
239 |
+
img = details["thumb"]
|
240 |
+
cap = _["play_10"].format(details["title"], details["duration_min"])
|
241 |
+
elif "playlist" in url:
|
242 |
+
spotify = True
|
243 |
+
try:
|
244 |
+
details, plist_id = await Apple.playlist(url)
|
245 |
+
except:
|
246 |
+
return await mystic.edit_text(_["play_3"])
|
247 |
+
streamtype = "playlist"
|
248 |
+
plist_type = "apple"
|
249 |
+
cap = _["play_12"].format(app.mention, message.from_user.mention)
|
250 |
+
img = url
|
251 |
+
else:
|
252 |
+
return await mystic.edit_text(_["play_3"])
|
253 |
+
elif await Resso.valid(url):
|
254 |
+
try:
|
255 |
+
details, track_id = await Resso.track(url)
|
256 |
+
except:
|
257 |
+
return await mystic.edit_text(_["play_3"])
|
258 |
+
streamtype = "youtube"
|
259 |
+
img = details["thumb"]
|
260 |
+
cap = _["play_10"].format(details["title"], details["duration_min"])
|
261 |
+
elif await SoundCloud.valid(url):
|
262 |
+
try:
|
263 |
+
details, track_path = await SoundCloud.download(url)
|
264 |
+
except:
|
265 |
+
return await mystic.edit_text(_["play_3"])
|
266 |
+
duration_sec = details["duration_sec"]
|
267 |
+
if duration_sec > config.DURATION_LIMIT:
|
268 |
+
return await mystic.edit_text(
|
269 |
+
_["play_6"].format(
|
270 |
+
config.DURATION_LIMIT_MIN,
|
271 |
+
app.mention,
|
272 |
+
)
|
273 |
+
)
|
274 |
+
try:
|
275 |
+
await stream(
|
276 |
+
_,
|
277 |
+
mystic,
|
278 |
+
user_id,
|
279 |
+
details,
|
280 |
+
chat_id,
|
281 |
+
user_name,
|
282 |
+
message.chat.id,
|
283 |
+
streamtype="soundcloud",
|
284 |
+
forceplay=fplay,
|
285 |
+
)
|
286 |
+
except Exception as e:
|
287 |
+
print(f"Error: {e}")
|
288 |
+
ex_type = type(e).__name__
|
289 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
290 |
+
return await mystic.edit_text(err)
|
291 |
+
return await mystic.delete()
|
292 |
+
else:
|
293 |
+
try:
|
294 |
+
await Aviax.stream_call(url)
|
295 |
+
except NoActiveGroupCall:
|
296 |
+
await mystic.edit_text(_["black_9"])
|
297 |
+
return await app.send_message(
|
298 |
+
chat_id=config.LOG_GROUP_ID,
|
299 |
+
text=_["play_17"],
|
300 |
+
)
|
301 |
+
except Exception as e:
|
302 |
+
print(f"Error: {e}")
|
303 |
+
return await mystic.edit_text(_["general_2"].format(type(e).__name__))
|
304 |
+
await mystic.edit_text(_["str_2"])
|
305 |
+
try:
|
306 |
+
await stream(
|
307 |
+
_,
|
308 |
+
mystic,
|
309 |
+
message.from_user.id,
|
310 |
+
url,
|
311 |
+
chat_id,
|
312 |
+
message.from_user.first_name,
|
313 |
+
message.chat.id,
|
314 |
+
video=video,
|
315 |
+
streamtype="index",
|
316 |
+
forceplay=fplay,
|
317 |
+
)
|
318 |
+
except Exception as e:
|
319 |
+
print(f"Error: {e}")
|
320 |
+
ex_type = type(e).__name__
|
321 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
322 |
+
return await mystic.edit_text(err)
|
323 |
+
return await play_logs(message, streamtype="M3u8 or Index Link")
|
324 |
+
else:
|
325 |
+
if len(message.command) < 2:
|
326 |
+
buttons = botplaylist_markup(_)
|
327 |
+
return await mystic.edit_text(
|
328 |
+
_["play_18"],
|
329 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
330 |
+
)
|
331 |
+
slider = True
|
332 |
+
query = message.text.split(None, 1)[1]
|
333 |
+
if "-v" in query:
|
334 |
+
query = query.replace("-v", "")
|
335 |
+
try:
|
336 |
+
details, track_id = await YouTube.track(query)
|
337 |
+
except:
|
338 |
+
return await mystic.edit_text(_["play_3"])
|
339 |
+
streamtype = "youtube"
|
340 |
+
if str(playmode) == "Direct":
|
341 |
+
if not plist_type:
|
342 |
+
if details["duration_min"]:
|
343 |
+
duration_sec = time_to_seconds(details["duration_min"])
|
344 |
+
if duration_sec > config.DURATION_LIMIT:
|
345 |
+
return await mystic.edit_text(
|
346 |
+
_["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
|
347 |
+
)
|
348 |
+
else:
|
349 |
+
buttons = livestream_markup(
|
350 |
+
_,
|
351 |
+
track_id,
|
352 |
+
user_id,
|
353 |
+
"v" if video else "a",
|
354 |
+
"c" if channel else "g",
|
355 |
+
"f" if fplay else "d",
|
356 |
+
)
|
357 |
+
return await mystic.edit_text(
|
358 |
+
_["play_13"],
|
359 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
360 |
+
)
|
361 |
+
try:
|
362 |
+
await stream(
|
363 |
+
_,
|
364 |
+
mystic,
|
365 |
+
user_id,
|
366 |
+
details,
|
367 |
+
chat_id,
|
368 |
+
user_name,
|
369 |
+
message.chat.id,
|
370 |
+
video=video,
|
371 |
+
streamtype=streamtype,
|
372 |
+
spotify=spotify,
|
373 |
+
forceplay=fplay,
|
374 |
+
)
|
375 |
+
except Exception as e:
|
376 |
+
print(f"Error: {e}")
|
377 |
+
ex_type = type(e).__name__
|
378 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
379 |
+
return await mystic.edit_text(err)
|
380 |
+
await mystic.delete()
|
381 |
+
return await play_logs(message, streamtype=streamtype)
|
382 |
+
else:
|
383 |
+
if plist_type:
|
384 |
+
ran_hash = "".join(
|
385 |
+
random.choices(string.ascii_uppercase + string.digits, k=10)
|
386 |
+
)
|
387 |
+
lyrical[ran_hash] = plist_id
|
388 |
+
buttons = playlist_markup(
|
389 |
+
_,
|
390 |
+
ran_hash,
|
391 |
+
message.from_user.id,
|
392 |
+
plist_type,
|
393 |
+
"c" if channel else "g",
|
394 |
+
"f" if fplay else "d",
|
395 |
+
)
|
396 |
+
await mystic.delete()
|
397 |
+
await message.reply_photo(
|
398 |
+
photo=img,
|
399 |
+
caption=cap,
|
400 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
401 |
+
)
|
402 |
+
return await play_logs(message, streamtype=f"Playlist : {plist_type}")
|
403 |
+
else:
|
404 |
+
if slider:
|
405 |
+
buttons = slider_markup(
|
406 |
+
_,
|
407 |
+
track_id,
|
408 |
+
message.from_user.id,
|
409 |
+
query,
|
410 |
+
0,
|
411 |
+
"c" if channel else "g",
|
412 |
+
"f" if fplay else "d",
|
413 |
+
)
|
414 |
+
await mystic.delete()
|
415 |
+
await message.reply_photo(
|
416 |
+
photo=details["thumb"],
|
417 |
+
caption=_["play_10"].format(
|
418 |
+
details["title"].title(),
|
419 |
+
details["duration_min"],
|
420 |
+
),
|
421 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
422 |
+
)
|
423 |
+
return await play_logs(message, streamtype=f"Searched on Youtube")
|
424 |
+
else:
|
425 |
+
buttons = track_markup(
|
426 |
+
_,
|
427 |
+
track_id,
|
428 |
+
message.from_user.id,
|
429 |
+
"c" if channel else "g",
|
430 |
+
"f" if fplay else "d",
|
431 |
+
)
|
432 |
+
await mystic.delete()
|
433 |
+
await message.reply_photo(
|
434 |
+
photo=img,
|
435 |
+
caption=cap,
|
436 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
437 |
+
)
|
438 |
+
return await play_logs(message, streamtype=f"URL Searched Inline")
|
439 |
+
|
440 |
+
|
441 |
+
@app.on_callback_query(filters.regex("MusicStream") & ~BANNED_USERS)
|
442 |
+
@languageCB
|
443 |
+
async def play_music(client, CallbackQuery, _):
|
444 |
+
callback_data = CallbackQuery.data.strip()
|
445 |
+
callback_request = callback_data.split(None, 1)[1]
|
446 |
+
vidid, user_id, mode, cplay, fplay = callback_request.split("|")
|
447 |
+
if CallbackQuery.from_user.id != int(user_id):
|
448 |
+
try:
|
449 |
+
return await CallbackQuery.answer(_["playcb_1"], show_alert=True)
|
450 |
+
except:
|
451 |
+
return
|
452 |
+
try:
|
453 |
+
chat_id, channel = await get_channeplayCB(_, cplay, CallbackQuery)
|
454 |
+
except:
|
455 |
+
return
|
456 |
+
user_name = CallbackQuery.from_user.first_name
|
457 |
+
try:
|
458 |
+
await CallbackQuery.message.delete()
|
459 |
+
await CallbackQuery.answer()
|
460 |
+
except:
|
461 |
+
pass
|
462 |
+
mystic = await CallbackQuery.message.reply_text(
|
463 |
+
_["play_2"].format(channel) if channel else _["play_1"]
|
464 |
+
)
|
465 |
+
try:
|
466 |
+
details, track_id = await YouTube.track(vidid, True)
|
467 |
+
except:
|
468 |
+
return await mystic.edit_text(_["play_3"])
|
469 |
+
if details["duration_min"]:
|
470 |
+
duration_sec = time_to_seconds(details["duration_min"])
|
471 |
+
if duration_sec > config.DURATION_LIMIT:
|
472 |
+
return await mystic.edit_text(
|
473 |
+
_["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
|
474 |
+
)
|
475 |
+
else:
|
476 |
+
buttons = livestream_markup(
|
477 |
+
_,
|
478 |
+
track_id,
|
479 |
+
CallbackQuery.from_user.id,
|
480 |
+
mode,
|
481 |
+
"c" if cplay == "c" else "g",
|
482 |
+
"f" if fplay else "d",
|
483 |
+
)
|
484 |
+
return await mystic.edit_text(
|
485 |
+
_["play_13"],
|
486 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
487 |
+
)
|
488 |
+
video = True if mode == "v" else None
|
489 |
+
ffplay = True if fplay == "f" else None
|
490 |
+
try:
|
491 |
+
await stream(
|
492 |
+
_,
|
493 |
+
mystic,
|
494 |
+
CallbackQuery.from_user.id,
|
495 |
+
details,
|
496 |
+
chat_id,
|
497 |
+
user_name,
|
498 |
+
CallbackQuery.message.chat.id,
|
499 |
+
video,
|
500 |
+
streamtype="youtube",
|
501 |
+
forceplay=ffplay,
|
502 |
+
)
|
503 |
+
except Exception as e:
|
504 |
+
print(f"Error: {e}")
|
505 |
+
ex_type = type(e).__name__
|
506 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
507 |
+
return await mystic.edit_text(err)
|
508 |
+
return await mystic.delete()
|
509 |
+
|
510 |
+
|
511 |
+
@app.on_callback_query(filters.regex("AnonymousAdmin") & ~BANNED_USERS)
|
512 |
+
async def anonymous_check(client, CallbackQuery):
|
513 |
+
try:
|
514 |
+
await CallbackQuery.answer(
|
515 |
+
"» ʀᴇᴠᴇʀᴛ ʙᴀᴄᴋ ᴛᴏ ᴜsᴇʀ ᴀᴄᴄᴏᴜɴᴛ :\n\nᴏᴘᴇɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ sᴇᴛᴛɪɴɢs.\n-> ᴀᴅᴍɪɴɪsᴛʀᴀᴛᴏʀs\n-> ᴄʟɪᴄᴋ ᴏɴ ʏᴏᴜʀ ɴᴀᴍᴇ\n-> ᴜɴᴄʜᴇᴄᴋ ᴀɴᴏɴʏᴍᴏᴜs ᴀᴅᴍɪɴ ᴘᴇʀᴍɪssɪᴏɴs.",
|
516 |
+
show_alert=True,
|
517 |
+
)
|
518 |
+
except:
|
519 |
+
pass
|
520 |
+
|
521 |
+
|
522 |
+
@app.on_callback_query(filters.regex("AviaxPlaylists") & ~BANNED_USERS)
|
523 |
+
@languageCB
|
524 |
+
async def play_playlists_command(client, CallbackQuery, _):
|
525 |
+
callback_data = CallbackQuery.data.strip()
|
526 |
+
callback_request = callback_data.split(None, 1)[1]
|
527 |
+
(
|
528 |
+
videoid,
|
529 |
+
user_id,
|
530 |
+
ptype,
|
531 |
+
mode,
|
532 |
+
cplay,
|
533 |
+
fplay,
|
534 |
+
) = callback_request.split("|")
|
535 |
+
if CallbackQuery.from_user.id != int(user_id):
|
536 |
+
try:
|
537 |
+
return await CallbackQuery.answer(_["playcb_1"], show_alert=True)
|
538 |
+
except:
|
539 |
+
return
|
540 |
+
try:
|
541 |
+
chat_id, channel = await get_channeplayCB(_, cplay, CallbackQuery)
|
542 |
+
except:
|
543 |
+
return
|
544 |
+
user_name = CallbackQuery.from_user.first_name
|
545 |
+
await CallbackQuery.message.delete()
|
546 |
+
try:
|
547 |
+
await CallbackQuery.answer()
|
548 |
+
except:
|
549 |
+
pass
|
550 |
+
mystic = await CallbackQuery.message.reply_text(
|
551 |
+
_["play_2"].format(channel) if channel else _["play_1"]
|
552 |
+
)
|
553 |
+
videoid = lyrical.get(videoid)
|
554 |
+
video = Tr
|