diff --git a/Dockerfile b/Dockerfile index 8f2a774..7a0760f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,4 +5,4 @@ COPY . /py WORKDIR /py RUN pip3 install -U pip RUN pip3 install -U -r requirements.txt -CMD python3 -m program +CMD ["python3", "main.py"] diff --git a/Procfile b/Procfile index 1bb71de..eb131d6 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -worker: python3 -m program +worker: python3 main.py diff --git a/config.py b/config.py index 255a03d..6765f10 100644 --- a/config.py +++ b/config.py @@ -22,6 +22,6 @@ SUDO_USERS = list(map(int, getenv("SUDO_USERS").split())) COMMAND_PREFIXES = list(getenv("COMMAND_PREFIXES", "/ ! .").split()) ALIVE_IMG = getenv("ALIVE_IMG", "https://telegra.ph/file/c83b000f004f01897fe18.png") DURATION_LIMIT = int(getenv("DURATION_LIMIT", "60")) -IMG_1 = getenv("IMG_1", "https://telegra.ph/file/92674c567ef7eb72521d2.png") -IMG_2 = getenv("IMG_2", "https://telegra.ph/file/9aa0eb8e4703e6a1d94d7.png") -IMG_3 = getenv("IMG_3", "https://telegra.ph/file/84568c753c738d7cfed46.png") +IMG_1 = getenv("IMG_1", "https://telegra.ph/file/d6f92c979ad96b2031cba.png") +IMG_2 = getenv("IMG_2", "https://telegra.ph/file/6213d2673486beca02967.png") +IMG_3 = getenv("IMG_3", "https://telegra.ph/file/f02efde766160d3ff52d6.png") diff --git a/heroku.yml b/heroku.yml index 65e2ed0..cdeba04 100644 --- a/heroku.yml +++ b/heroku.yml @@ -1,5 +1,3 @@ build: docker: - worker: Dockerfile -run: - worker: python3 -m program + worker: Dockerfile diff --git a/main.py b/main.py new file mode 100644 index 0000000..02df684 --- /dev/null +++ b/main.py @@ -0,0 +1,18 @@ +import asyncio + +from driver.veez import bot, call_py +from pytgcalls import idle + + +async def mulai_bot(): + print("[INFO]: STARTING BOT CLIENT") + await bot.start() + print("[INFO]: STARTING PYTGCALLS CLIENT") + await call_py.start() + await idle() + print("[INFO]: STOPPING BOT") + await bot.stop() + + +loop = asyncio.get_event_loop() +loop.run_until_complete(mulai_bot()) diff --git a/program/__main__.py b/program/__main__.py deleted file mode 100644 index 3c4893b..0000000 --- a/program/__main__.py +++ /dev/null @@ -1,13 +0,0 @@ -import os -from pyrogram import Client, idle -from pytgcalls import PyTgCalls -from pytgcalls import idle as engine -from driver.veez import bot, call_py -from program import __version__ - -bot.start() -print(f"program v{__version__} started !") -call_py.start() -print("program client started !") -engine() -idle() diff --git a/program/admins.py b/program/admins.py index d8d57ab..7759cee 100644 --- a/program/admins.py +++ b/program/admins.py @@ -1,12 +1,12 @@ from cache.admins import admins -from driver.filters import command, other_filters -from pyrogram import Client, filters -from driver.veez import call_py, bot -from driver.queues import QUEUE, clear_queue +from config import BOT_USERNAME, GROUP_SUPPORT, IMG_3, UPDATES_CHANNEL from driver.decorators import authorized_users_only +from driver.filters import command, other_filters +from driver.queues import QUEUE, clear_queue from driver.utils import skip_current_song, skip_item -from config import BOT_USERNAME, IMG_3, GROUP_SUPPORT, UPDATES_CHANNEL -from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup +from driver.veez import call_py +from pyrogram import Client +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message @Client.on_message(command(["reload", f"reload@{BOT_USERNAME}"]) & other_filters) @@ -26,89 +26,114 @@ async def update_admin(client, message): @Client.on_message(command(["skip", f"skip@{BOT_USERNAME}", "vskip"]) & other_filters) @authorized_users_only async def skip(client, m: Message): - - keyboard = InlineKeyboardMarkup( + + keyboard = InlineKeyboardMarkup( + [ [ - [ - InlineKeyboardButton( - text="✨ ɢʀᴏᴜᴘ", - url=f"https://t.me/{GROUP_SUPPORT}"), - InlineKeyboardButton( - text="🌻 ᴄʜᴀɴɴᴇʟ", - url=f"https://t.me/{UPDATES_CHANNEL}") - ] + InlineKeyboardButton( + text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}" + ), + InlineKeyboardButton( + text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}" + ), ] - ) - - chat_id = m.chat.id - if len(m.command) < 2: - op = await skip_current_song(chat_id) - if op==0: - await m.reply("❌ nothing is currently playing") - elif op==1: - await m.reply("✅ __Queues__ is empty.\n\n• userbot leaving voice chat") - else: - await m.reply_photo( - photo=f"{IMG_3}", - caption=f"⏭ **Skipped to the next track.**\n\n🏷 **Name:** [{op[0]}]({op[1]})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, - ) - else: - skip = m.text.split(None, 1)[1] - OP = "🗑 **removed song from queue:**" - 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: - pass - else: - hm = await skip_item(chat_id, x) - if hm==0: - pass - else: - OP = OP + "\n" + f"**#{x}** - {hm}" - await m.reply(OP) + ] + ) + + chat_id = m.chat.id + if len(m.command) < 2: + op = await skip_current_song(chat_id) + if op == 0: + await m.reply("❌ nothing is currently playing") + elif op == 1: + await m.reply("✅ __Queues__ is empty.\n\n• userbot leaving voice chat") + else: + await m.reply_photo( + photo=f"{IMG_3}", + caption=f"⏭ **Skipped to the next track.**\n\n🏷 **Name:** [{op[0]}]({op[1]})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", + reply_markup=keyboard, + ) + else: + skip = m.text.split(None, 1)[1] + OP = "🗑 **removed song from queue:**" + 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: + pass + else: + hm = await skip_item(chat_id, x) + if hm == 0: + pass + else: + OP = OP + "\n" + f"**#{x}** - {hm}" + await m.reply(OP) -@Client.on_message(command(["stop", f"stop@{BOT_USERNAME}", "end", f"end@{BOT_USERNAME}", "vstop"]) & other_filters) +@Client.on_message( + command(["stop", f"stop@{BOT_USERNAME}", "end", f"end@{BOT_USERNAME}", "vstop"]) + & other_filters +) @authorized_users_only async def stop(client, m: Message): - chat_id = m.chat.id - if chat_id in QUEUE: - try: - await call_py.leave_group_call(chat_id) - clear_queue(chat_id) - await m.reply("✅ **streaming has ended.**") - except Exception as e: - await m.reply(f"🚫 **error:**\n\n`{e}`") - else: - await m.reply("❌ **nothing in streaming**") + chat_id = m.chat.id + if chat_id in QUEUE: + try: + await call_py.leave_group_call(chat_id) + clear_queue(chat_id) + await m.reply("✅ **streaming has ended.**") + except Exception as e: + await m.reply(f"🚫 **error:**\n\n`{e}`") + else: + await m.reply("❌ **nothing in streaming**") -@Client.on_message(command(["pause", f"pause@{BOT_USERNAME}", "vpause"]) & other_filters) +@Client.on_message( + command(["pause", f"pause@{BOT_USERNAME}", "vpause"]) & other_filters +) @authorized_users_only async def pause(client, m: Message): - chat_id = m.chat.id - if chat_id in QUEUE: - try: - await call_py.pause_stream(chat_id) - await m.reply("⏸ **Track paused.**\n\n• **To resume the stream, use the**\n» /resume command.") - except Exception as e: - await m.reply(f"🚫 **error:**\n\n`{e}`") - else: - await m.reply("❌ **nothing in streaming**") + chat_id = m.chat.id + if chat_id in QUEUE: + try: + await call_py.pause_stream(chat_id) + await m.reply( + "⏸ **Track paused.**\n\n• **To resume the stream, use the**\n» /resume command." + ) + except Exception as e: + await m.reply(f"🚫 **error:**\n\n`{e}`") + else: + await m.reply("❌ **nothing in streaming**") -@Client.on_message(command(["resume", f"resume@{BOT_USERNAME}", "vresume"]) & other_filters) +@Client.on_message( + command(["resume", f"resume@{BOT_USERNAME}", "vresume"]) & other_filters +) @authorized_users_only async def resume(client, m: Message): - chat_id = m.chat.id - if chat_id in QUEUE: - try: - await call_py.resume_stream(chat_id) - await m.reply("▶️ **Track resumed.**\n\n• **To pause the stream, use the**\n» /pause command.") - except Exception as e: - await m.reply(f"🚫 **error:**\n\n`{e}`") - else: - await m.reply("❌ **nothing in streaming**") + chat_id = m.chat.id + if chat_id in QUEUE: + try: + await call_py.resume_stream(chat_id) + await m.reply( + "▶️ **Track resumed.**\n\n• **To pause the stream, use the**\n» /pause command." + ) + except Exception as e: + await m.reply(f"🚫 **error:**\n\n`{e}`") + else: + await m.reply("❌ **nothing in streaming**") + + +@Client.on_message( + command(["volume", f"volume@{BOT_USERNAME}", "vol"]) & other_filters +) +@authorized_users_only +async def change_volume(client, m: Message): + range = m.command[1] + chat_id = m.chat.id + try: + await call_py.change_volume_call(chat_id, volume=int(range)) + await m.reply(f"✅ **volume set to** `{range}`%") + except Exception as e: + await m.reply(f"🚫 **error:**\n\n{e}") diff --git a/program/callback.py b/program/callback.py index 7031c7d..0131705 100644 --- a/program/callback.py +++ b/program/callback.py @@ -20,7 +20,7 @@ async def cbstart(_, query: CallbackQuery): 💡 **Find out all the Bot's commands and how they work by clicking on the » 📚 Commands button!** -❔ **To know how to use this bot, please click on the » ❓ Basic Guide button!**""", +🔖 **To know how to use this bot, please click on the » ❓ Basic Guide button!**""", reply_markup=InlineKeyboardMarkup( [ [ @@ -58,11 +58,14 @@ async def cbguides(_, query: CallbackQuery): await query.edit_message_text( f"""❓ **Basic Guide for using this bot:** -1.) **first, add me to your group.** -2.) **then promote me as admin and give all permissions except anonymous admin.** -3.) **add @{ASSISTANT_NAME} to your group or type /userbotjoin to invite her.** -4.) **turn on the video chat first before start to play video.** -5.) **all the command list you can see on » 📚 Commands button, find it on start home, tap the » Go Back button below.** +1.) **First, add me to your group.** +2.) **Then, promote me as administrator and give all permissions except Anonymous Admin.** +3.) **After promoting me, type /reload in group to refresh the admin data.** +3.) **Add @{ASSISTANT_NAME} to your group or type /userbotjoin to invite her.** +4.) **Turn on the video chat first before start to play video/music.** +5.) **Sometimes, reloading the bot by using /reload command can help you to fix some problem.** + +📌 **If the userbot not joined to video chat, make sure if the video chat already turned on, or type /userbotleave then type /userbotjoin again.** 💡 **If you have a follow-up questions about this bot, you can tell it on my support chat here: @{GROUP_SUPPORT}** @@ -74,34 +77,85 @@ async def cbguides(_, query: CallbackQuery): @Client.on_callback_query(filters.regex("cbcmds")) -async def cbhelps(_, query: CallbackQuery): +async def cbcmds(_, query: CallbackQuery): await query.edit_message_text( - f"""📚 Here is the Commands list: + f"""✨ **Hello [{query.message.chat.first_name}](tg://user?id={query.message.chat.id}) !** -» /play - play music on voice chat -» /stream - enter the radio link -» /vplay - play video on video chat -» /vstream - for m3u8/live link +» **press the button below to read the explanation and see the list of available commands !** + +⚡ __Powered by {BOT_NAME} A.I__""", + reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton("👷🏻 Admin Cmd", callback_data="cbadmin"), + InlineKeyboardButton("🧙🏻 Sudo Cmd", callback_data="cbsudo"), + ],[ + InlineKeyboardButton("📚 Basic Cmd", callback_data="cbbasic") + ],[ + InlineKeyboardButton("🔙 Go Back", callback_data="cbstart") + ], + ] + ), + ) + + +@Client.on_callback_query(filters.regex("cbbasic")) +async def cbbasic(_, query: CallbackQuery): + await query.edit_message_text( + f"""🏮 here is the basic commands: + +» /play (song name/link) - play music on video chat +» /stream (query/link) - stream the yt live/radio/m3u8 live music +» /vplay (video name/link) - play video on video chat +» /vstream - play live video from yt live/m3u8 » /playlist - show you the playlist » /video (query) - download video from youtube » /song (query) - download song from youtube » /lyric (query) - scrap the song lyric » /search (query) - search a youtube video link -» /queue - show you the queue list (admin only) -» /pause - pause the stream (admin only) -» /resume - resume the stream (admin only) -» /skip - switch to next stream (admin only) -» /stop - stop the streaming (admin only) -» /userbotjoin - invite the userbot to join chat (admin only) -» /userbotleave - order userbot to leave from group (admin only) -» /reload - update the admin list (admin only) -» /rmw - clean raw files (sudo only) -» /rmd - clean downloaded files (sudo only) -» /leaveall - order userbot leave from all group (sudo only) + +» /ping - show the bot ping status +» /uptime - show the bot uptime status +» /alive - show the bot alive info (in group) + +⚡️ __Powered by {BOT_NAME} AI__""", + reply_markup=InlineKeyboardMarkup( + [[InlineKeyboardButton("🔙 Go Back", callback_data="cbcmds")]] + ), + ) + + +@Client.on_callback_query(filters.regex("cbadmin")) +async def cbadmin(_, query: CallbackQuery): + await query.edit_message_text( + f"""🏮 here is the admin commands: + +» /pause - pause the stream +» /resume - resume the stream +» /skip - switch to next stream +» /stop - stop the streaming +» /reload - reload bot and refresh the admin data +» /userbotjoin - invite the userbot to join group +» /userbotleave - order userbot to leave from group + +⚡️ __Powered by {BOT_NAME} AI__""", + reply_markup=InlineKeyboardMarkup( + [[InlineKeyboardButton("🔙 Go Back", callback_data="cbcmds")]] + ), + ) + +@Client.on_callback_query(filters.regex("cbsudo")) +async def cbsudo(_, query: CallbackQuery): + await query.edit_message_text( + f"""🏮 here is the sudo commands: + +» /rmw - clean all raw files +» /rmd - clean all downloaded files +» /leaveall - order userbot to leave from all group ⚡ __Powered by {BOT_NAME} AI__""", reply_markup=InlineKeyboardMarkup( - [[InlineKeyboardButton("🔙 Go Back", callback_data="cbstart")]] + [[InlineKeyboardButton("🔙 Go Back", callback_data="cbcmds")]] ), ) diff --git a/program/music.py b/program/music.py index 618ee4b..180bcbc 100644 --- a/program/music.py +++ b/program/music.py @@ -2,250 +2,258 @@ # Commit Start Date 20/10/2021 # Finished On 28/10/2021 -import os -import re import asyncio -from driver.veez import call_py -from pytgcalls import StreamType +import re + +from config import BOT_USERNAME, GROUP_SUPPORT, IMG_1, IMG_2, UPDATES_CHANNEL from driver.filters import command, other_filters -from pyrogram import Client, filters -from youtubesearchpython import VideosSearch from driver.queues import QUEUE, add_to_queue +from driver.veez import call_py +from pyrogram import Client +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message +from pytgcalls import StreamType from pytgcalls.types.input_stream import AudioPiped -from config import BOT_USERNAME, IMG_1, IMG_2, GROUP_SUPPORT, UPDATES_CHANNEL -from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup +from youtubesearchpython import VideosSearch def ytsearch(query): - try: - search = VideosSearch(query, limit=1) - for r in search.result()["result"]: - ytid = r['id'] - if len(r['title']) > 34: - songname = r['title'][:60] + "..." - else: - songname = r['title'] - url = f"https://www.youtube.com/watch?v={ytid}" - return [songname, url] - except Exception as e: - print(e) - return 0 + try: + search = VideosSearch(query, limit=1) + for r in search.result()["result"]: + ytid = r["id"] + if len(r["title"]) > 34: + songname = r["title"][:60] + "..." + else: + songname = r["title"] + url = f"https://www.youtube.com/watch?v={ytid}" + return [songname, url] + except Exception as e: + print(e) + return 0 async def ytdl(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() - if stdout: - return 1, stdout.decode().split('\n')[0] - else: - return 0, stderr.decode() + 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() + if stdout: + return 1, stdout.decode().split("\n")[0] + else: + return 0, stderr.decode() @Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters) -async def play(client, m: Message): - - keyboard = InlineKeyboardMarkup( +async def play(_, m: Message): + + keyboard = InlineKeyboardMarkup( + [ [ - [ - InlineKeyboardButton( - text="✨ ɢʀᴏᴜᴘ", - url=f"https://t.me/{GROUP_SUPPORT}"), - InlineKeyboardButton( - text="🌻 ᴄʜᴀɴɴᴇʟ", - url=f"https://t.me/{UPDATES_CHANNEL}") - ] + InlineKeyboardButton( + text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}" + ), + InlineKeyboardButton( + text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}" + ), ] - ) - - replied = m.reply_to_message - chat_id = m.chat.id - if replied: - if replied.audio or replied.voice: - suhu = await replied.reply("📥 **downloading audio...**") - dl = await replied.download() - link = replied.link - if replied.audio: - if replied.audio.title: - songname = replied.audio.title[:60] + "..." + ] + ) + + replied = m.reply_to_message + chat_id = m.chat.id + if replied: + if replied.audio or replied.voice: + suhu = await replied.reply("📥 **downloading audio...**") + dl = await replied.download() + link = replied.link + if replied.audio: + if replied.audio.title: + songname = replied.audio.title[:60] + "..." + else: + songname = replied.audio.file_name[:60] + "..." + elif replied.voice: + songname = "Voice Note" + if chat_id in QUEUE: + pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0) + await suhu.delete() + await m.reply_photo( + photo=f"{IMG_1}", + caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", + reply_markup=keyboard, + ) else: - songname = replied.audio.file_name[:60] + "..." - elif replied.voice: - songname = "Voice Note" - if chat_id in QUEUE: - pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0) - await suhu.delete() - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", - reply_markup=keyboard, + await call_py.join_group_call( + chat_id, + AudioPiped( + dl, + ), + stream_type=StreamType().pulse_stream, + ) + add_to_queue(chat_id, songname, dl, link, "Audio", 0) + await suhu.delete() + await m.reply_photo( + photo=f"{IMG_2}", + caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", + reply_markup=keyboard, + ) + else: + if len(m.command) < 2: + await m.reply( + "» reply to an **audio file** or **give something to search.**" + ) + else: + suhu = await m.reply("🔎 **searching...**") + query = m.text.split(None, 1)[1] + search = ytsearch(query) + if search == 0: + await suhu.edit("❌ **no results found.**") + else: + songname = search[0] + url = search[1] + veez, ytlink = await ytdl(url) + if veez == 0: + await suhu.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") + else: + if chat_id in QUEUE: + pos = add_to_queue( + chat_id, songname, ytlink, url, "Audio", 0 + ) + await suhu.delete() + await m.reply_photo( + photo=f"{IMG_1}", + caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", + reply_markup=keyboard, + ) + else: + try: + await call_py.join_group_call( + chat_id, + AudioPiped( + ytlink, + ), + stream_type=StreamType().pulse_stream, + ) + add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) + await suhu.delete() + await m.reply_photo( + photo=f"{IMG_2}", + caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", + reply_markup=keyboard, + ) + except Exception as ep: + await m.reply_text(f"🚫 error: `{ep}`") + + else: + if len(m.command) < 2: + await m.reply( + "» reply to an **audio file** or **give something to search.**" ) - else: - await call_py.join_group_call( - chat_id, - AudioPiped( - dl, - ), - stream_type=StreamType().pulse_stream, - ) - add_to_queue(chat_id, songname, dl, link, "Audio", 0) - await m.reply_photo( - photo=f"{IMG_2}", - caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, - ) - else: - if len(m.command) < 2: - await m.reply("» reply to an **audio file** or **give something to search.**") - else: + else: suhu = await m.reply("🔎 **searching...**") query = m.text.split(None, 1)[1] search = ytsearch(query) - if search==0: - await suhu.edit("❌ **no results found.**") + if search == 0: + await suhu.edit("❌ **no results found.**") else: - songname = search[0] - url = search[1] - veez, ytlink = await ytdl(url) - if veez==0: - await suhu.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") - else: - if chat_id in QUEUE: - pos = add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) - await suhu.delete() - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", - reply_markup=keyboard, - ) - else: - try: - await call_py.join_group_call( - chat_id, - AudioPiped( - ytlink, - ), - stream_type=StreamType().pulse_stream, - ) - add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) + songname = search[0] + url = search[1] + veez, ytlink = await ytdl(url) + if veez == 0: + await suhu.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") + else: + if chat_id in QUEUE: + pos = add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) await suhu.delete() await m.reply_photo( - photo=f"{IMG_2}", - caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, + photo=f"{IMG_1}", + caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", + reply_markup=keyboard, ) - except Exception as ep: - await m.reply_text(f"🚫 error: `{ep}`") - - else: - if len(m.command) < 2: - await m.reply("» reply to an **audio file** or **give something to search.**") - else: - suhu = await m.reply("🔎 **searching...**") - query = m.text.split(None, 1)[1] - search = ytsearch(query) - if search==0: - await suhu.edit("❌ **no results found.**") - else: - songname = search[0] - url = search[1] - veez, ytlink = await ytdl(url) - if veez==0: - await suhu.edit(f"❌ youtube-dl issues detected\n\n» `{ytlink}`") - else: - if chat_id in QUEUE: - pos = add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) - await suhu.delete() - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", - reply_markup=keyboard, - ) - else: - try: - await call_py.join_group_call( - chat_id, - AudioPiped( - ytlink, - ), - stream_type=StreamType().pulse_stream, - ) - add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) - await suhu.delete() - await m.reply_photo( - photo=f"{IMG_2}", - caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, - ) - except Exception as ep: - await m.reply_text(f"🚫 error: `{ep}`") + else: + try: + await call_py.join_group_call( + chat_id, + AudioPiped( + ytlink, + ), + stream_type=StreamType().pulse_stream, + ) + add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) + await suhu.delete() + await m.reply_photo( + photo=f"{IMG_2}", + caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", + reply_markup=keyboard, + ) + except Exception as ep: + await m.reply_text(f"🚫 error: `{ep}`") + # stream is used for live streaming only @Client.on_message(command(["stream", f"stream@{BOT_USERNAME}"]) & other_filters) -async def stream(client, m: Message): - - keyboard = InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton( - text="✨ ɢʀᴏᴜᴘ", - url=f"https://t.me/{GROUP_SUPPORT}"), - InlineKeyboardButton( - text="🌻 ᴄʜᴀɴɴᴇʟ", - url=f"https://t.me/{UPDATES_CHANNEL}") - ] - ] - ) - - chat_id = m.chat.id - if len(m.command) < 2: - await m.reply("» give me a live-link/m3u8 url/youtube link to stream.") - else: - link = m.text.split(None, 1)[1] - suhu = await m.reply("🔄 **processing stream...**") +async def stream(_, m: Message): - regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+" - match = re.match(regex,link) - if match: - veez, livelink = await ytdl(link) - else: - livelink = link - veez = 1 - - if veez==0: - await suhu.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") - else: - if chat_id in QUEUE: - pos = add_to_queue(chat_id, "Radio", livelink, link, "Audio", 0) - await suhu.delete() - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to the queue**\n\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", - reply_markup=keyboard, - ) - else: - try: - await call_py.join_group_call( - chat_id, - AudioPiped( - livelink, - ), - stream_type=StreamType().pulse_stream, - ) - add_to_queue(chat_id, "Radio", livelink, link, "Audio", 0) - await suhu.delete() - await m.reply_photo( - photo=f"{IMG_2}", - caption=f"💡 **[Radio live]({link}) stream started.**\n\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, - ) - except Exception as ep: - await m.reply_text(f"🚫 error: `{ep}`") + keyboard = InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton( + text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}" + ), + InlineKeyboardButton( + text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}" + ), + ] + ] + ) + + chat_id = m.chat.id + if len(m.command) < 2: + await m.reply("» give me a live-link/m3u8 url/youtube link to stream.") + else: + link = m.text.split(None, 1)[1] + suhu = await m.reply("🔄 **processing stream...**") + + regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+" + match = re.match(regex, link) + if match: + veez, livelink = await ytdl(link) + else: + livelink = link + veez = 1 + + if veez == 0: + await suhu.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") + else: + if chat_id in QUEUE: + pos = add_to_queue(chat_id, "Radio", livelink, link, "Audio", 0) + await suhu.delete() + await m.reply_photo( + photo=f"{IMG_1}", + caption=f"💡 **Track added to the queue**\n\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", + reply_markup=keyboard, + ) + else: + try: + await call_py.join_group_call( + chat_id, + AudioPiped( + livelink, + ), + stream_type=StreamType().pulse_stream, + ) + add_to_queue(chat_id, "Radio", livelink, link, "Audio", 0) + await suhu.delete() + await m.reply_photo( + photo=f"{IMG_2}", + caption=f"💡 **[Radio live]({link}) stream started.**\n\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", + reply_markup=keyboard, + ) + except Exception as ep: + await m.reply_text(f"🚫 error: `{ep}`") diff --git a/program/start.py b/program/start.py index ca4ea9f..2e57163 100644 --- a/program/start.py +++ b/program/start.py @@ -12,7 +12,6 @@ from config import ( UPDATES_CHANNEL, ) from program import __version__ -from driver.decorators import sudo_users_only from driver.filters import command, other_filters from pyrogram import Client, filters from pyrogram import __version__ as pyrover @@ -58,7 +57,7 @@ async def start_(client: Client, message: Message): 💡 **Find out all the Bot's commands and how they work by clicking on the » 📚 Commands button!** -❔ **To know how to use this bot, please click on the » ❓ Basic Guide button!** +🔖 **To know how to use this bot, please click on the » ❓ Basic Guide button!** """, reply_markup=InlineKeyboardMarkup( [ @@ -71,7 +70,7 @@ async def start_(client: Client, message: Message): [InlineKeyboardButton("❓ Basic Guide", callback_data="cbhowtouse")], [ InlineKeyboardButton("📚 Commands", callback_data="cbcmds"), - InlineKeyboardButton("💝 Donate", url=f"https://t.me/{OWNER_NAME}"), + InlineKeyboardButton("❤️ Donate", url=f"https://t.me/{OWNER_NAME}"), ], [ InlineKeyboardButton( @@ -129,7 +128,6 @@ async def ping_pong(client: Client, message: Message): @Client.on_message(command(["uptime", f"uptime@{BOT_USERNAME}"]) & ~filters.edited) -@sudo_users_only async def get_uptime(client: Client, message: Message): current_time = datetime.utcnow() uptime_sec = (current_time - START_TIME).total_seconds() diff --git a/program/video.py b/program/video.py index 55040f8..b0afffa 100644 --- a/program/video.py +++ b/program/video.py @@ -2,298 +2,296 @@ # Commit Start Date 20/10/2021 # Finished On 28/10/2021 -import os -import re import asyncio -from driver.veez import call_py -from pytgcalls import StreamType -from pyrogram import Client, filters +import re + +from config import BOT_USERNAME, GROUP_SUPPORT, IMG_1, IMG_2, UPDATES_CHANNEL from driver.filters import command, other_filters -from youtubesearchpython import VideosSearch from driver.queues import QUEUE, add_to_queue +from driver.veez import call_py +from pyrogram import Client +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message +from pytgcalls import StreamType from pytgcalls.types.input_stream import AudioVideoPiped -from config import BOT_USERNAME, IMG_1, IMG_2, GROUP_SUPPORT, UPDATES_CHANNEL -from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup -from pytgcalls.types.input_stream.quality import HighQualityAudio, MediumQualityAudio -from pytgcalls.types.input_stream.quality import HighQualityVideo, MediumQualityVideo, LowQualityVideo +from pytgcalls.types.input_stream.quality import ( + HighQualityAudio, + HighQualityVideo, + LowQualityVideo, + MediumQualityVideo, +) +from youtubesearchpython import VideosSearch def ytsearch(query): - try: - search = VideosSearch(query, limit=1) - for r in search.result()["result"]: - ytid = r['id'] - if len(r['title']) > 34: - songname = r['title'][:60] + "..." - else: - songname = r['title'] - url = f"https://www.youtube.com/watch?v={ytid}" - return [songname, url] - except Exception as e: - print(e) - return 0 + try: + search = VideosSearch(query, limit=1) + for r in search.result()["result"]: + ytid = r["id"] + if len(r["title"]) > 34: + songname = r["title"][:60] + "..." + else: + songname = r["title"] + url = f"https://www.youtube.com/watch?v={ytid}" + return [songname, url] + except Exception as e: + print(e) + return 0 async def ytdl(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() - if stdout: - return 1, stdout.decode().split('\n')[0] - else: - return 0, stderr.decode() + 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() + if stdout: + return 1, stdout.decode().split("\n")[0] + else: + return 0, stderr.decode() @Client.on_message(command(["vplay", f"vplay@{BOT_USERNAME}"]) & other_filters) async def vplay(client, m: Message): - - keyboard = InlineKeyboardMarkup( + + keyboard = InlineKeyboardMarkup( + [ [ - [ - InlineKeyboardButton( - text="✨ ɢʀᴏᴜᴘ", - url=f"https://t.me/{GROUP_SUPPORT}"), - InlineKeyboardButton( - text="🌻 ᴄʜᴀɴɴᴇʟ", - url=f"https://t.me/{UPDATES_CHANNEL}") - ] + InlineKeyboardButton( + text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}" + ), + InlineKeyboardButton( + text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}" + ), ] - ) - - replied = m.reply_to_message - chat_id = m.chat.id - if replied: - if replied.video or replied.document: - loser = await replied.reply("📥 **downloading video...**") - dl = await replied.download() - link = replied.link - if len(m.command) < 2: - Q = 720 - else: - pq = m.text.split(None, 1)[1] - if pq == "720" or "480" or "360": - Q = int(pq) + ] + ) + + replied = m.reply_to_message + chat_id = m.chat.id + if replied: + if replied.video or replied.document: + loser = await replied.reply("📥 **downloading video...**") + dl = await replied.download() + link = replied.link + if len(m.command) < 2: + Q = 720 else: - Q = 720 - await loser.edit("» __only 720, 480, 360 allowed__ \n💡 **now streaming video in 720p**") - - if replied.video: - songname = replied.video.file_name[:60] + "..." - elif replied.document: - songname = replied.document.file_name[:60] + "..." - - if chat_id in QUEUE: - pos = add_to_queue(chat_id, songname, dl, link, "Video", Q) - await loser.delete() - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", - reply_markup=keyboard, + pq = m.text.split(None, 1)[1] + if pq == "720" or "480" or "360": + Q = int(pq) + else: + Q = 720 + await loser.edit( + "» __only 720, 480, 360 allowed__ \n💡 **now streaming video in 720p**" + ) + + if replied.video: + songname = replied.video.file_name[:60] + "..." + elif replied.document: + songname = replied.document.file_name[:60] + "..." + + if chat_id in QUEUE: + pos = add_to_queue(chat_id, songname, dl, link, "Video", Q) + await loser.delete() + await m.reply_photo( + photo=f"{IMG_1}", + caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", + reply_markup=keyboard, + ) + else: + if Q == 720: + amaze = HighQualityVideo() + elif Q == 480: + amaze = MediumQualityVideo() + elif Q == 360: + amaze = LowQualityVideo() + await call_py.join_group_call( + chat_id, + AudioVideoPiped(dl, HighQualityAudio(), amaze), + stream_type=StreamType().pulse_stream, + ) + add_to_queue(chat_id, songname, dl, link, "Video", Q) + await loser.delete() + await m.reply_photo( + photo=f"{IMG_2}", + caption=f"💡 **video streaming started.**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", + reply_markup=keyboard, + ) + else: + if len(m.command) < 2: + await m.reply( + "» reply to an **video file** or **give something to search.**" + ) + else: + loser = await m.reply("🔎 **searching...**") + query = m.text.split(None, 1)[1] + search = ytsearch(query) + Q = 720 + amaze = HighQualityVideo() + if search == 0: + await loser.edit("❌ **no results found.**") + else: + songname = search[0] + url = search[1] + veez, ytlink = await ytdl(url) + if veez == 0: + await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") + else: + if chat_id in QUEUE: + pos = add_to_queue( + chat_id, songname, ytlink, url, "Video", Q + ) + await loser.delete() + await m.reply_photo( + photo=f"{IMG_1}", + caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", + reply_markup=keyboard, + ) + else: + try: + await call_py.join_group_call( + chat_id, + AudioVideoPiped(ytlink, HighQualityAudio(), amaze), + stream_type=StreamType().pulse_stream, + ) + add_to_queue(chat_id, songname, ytlink, url, "Video", Q) + await loser.delete() + await m.reply_photo( + photo=f"{IMG_2}", + caption=f"💡 **video streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", + reply_markup=keyboard, + ) + except Exception as ep: + await m.reply_text(f"🚫 error: `{ep}`") + + else: + if len(m.command) < 2: + await m.reply( + "» reply to an **video file** or **give something to search.**" ) - else: - if Q==720: - amaze = HighQualityVideo() - elif Q==480: - amaze = MediumQualityVideo() - elif Q==360: - amaze = LowQualityVideo() - await call_py.join_group_call( - chat_id, - AudioVideoPiped( - dl, - HighQualityAudio(), - amaze - ), - stream_type=StreamType().pulse_stream, - ) - add_to_queue(chat_id, songname, dl, link, "Video", Q) - await loser.delete() - await m.reply_photo( - photo=f"{IMG_2}", - caption=f"💡 **video streaming started.**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, - ) - else: - if len(m.command) < 2: - await m.reply("» reply to an **video file** or **give something to search.**") - else: + else: loser = await m.reply("🔎 **searching...**") query = m.text.split(None, 1)[1] search = ytsearch(query) Q = 720 amaze = HighQualityVideo() - if search==0: - await loser.edit("❌ **no results found.**") + if search == 0: + await loser.edit("❌ **no results found.**") else: - songname = search[0] - url = search[1] - veez, ytlink = await ytdl(url) - if veez==0: - await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") - else: - if chat_id in QUEUE: - pos = add_to_queue(chat_id, songname, ytlink, url, "Video", Q) - await loser.delete() - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", - reply_markup=keyboard, - ) - else: - try: - await call_py.join_group_call( - chat_id, - AudioVideoPiped( - ytlink, - HighQualityAudio(), - amaze - ), - stream_type=StreamType().pulse_stream, - ) - add_to_queue(chat_id, songname, ytlink, url, "Video", Q) + songname = search[0] + url = search[1] + veez, ytlink = await ytdl(url) + if veez == 0: + await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") + else: + if chat_id in QUEUE: + pos = add_to_queue(chat_id, songname, ytlink, url, "Video", Q) await loser.delete() await m.reply_photo( - photo=f"{IMG_2}", - caption=f"💡 **video streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, + photo=f"{IMG_1}", + caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", + reply_markup=keyboard, ) - except Exception as ep: - await m.reply_text(f"🚫 error: `{ep}`") - - else: - if len(m.command) < 2: - await m.reply("» reply to an **video file** or **give something to search.**") - else: - loser = await m.reply("🔎 **searching...**") - query = m.text.split(None, 1)[1] - search = ytsearch(query) - Q = 720 - amaze = HighQualityVideo() - if search==0: - await loser.edit("❌ **no results found.**") - else: - songname = search[0] - url = search[1] - veez, ytlink = await ytdl(url) - if veez==0: - await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") - else: - if chat_id in QUEUE: - pos = add_to_queue(chat_id, songname, ytlink, url, "Video", Q) - await loser.delete() - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to the queue**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", - reply_markup=keyboard, - ) - else: - try: - await call_py.join_group_call( - chat_id, - AudioVideoPiped( - ytlink, - HighQualityAudio(), - amaze - ), - stream_type=StreamType().pulse_stream, - ) - add_to_queue(chat_id, songname, ytlink, url, "Video", Q) - await loser.delete() - await m.reply_photo( - photo=f"{IMG_2}", - caption=f"💡 **video streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, - ) - except Exception as ep: - await m.reply_text(f"🚫 error: `{ep}`") + else: + try: + await call_py.join_group_call( + chat_id, + AudioVideoPiped(ytlink, HighQualityAudio(), amaze), + stream_type=StreamType().pulse_stream, + ) + add_to_queue(chat_id, songname, ytlink, url, "Video", Q) + await loser.delete() + await m.reply_photo( + photo=f"{IMG_2}", + caption=f"💡 **video streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", + reply_markup=keyboard, + ) + except Exception as ep: + await m.reply_text(f"🚫 error: `{ep}`") @Client.on_message(command(["vstream", f"vstream@{BOT_USERNAME}"]) & other_filters) async def vstream(client, m: Message): - - keyboard = InlineKeyboardMarkup( + + keyboard = InlineKeyboardMarkup( + [ [ - [ - InlineKeyboardButton( - text="✨ ɢʀᴏᴜᴘ", - url=f"https://t.me/{GROUP_SUPPORT}"), - InlineKeyboardButton( - text="🌻 ᴄʜᴀɴɴᴇʟ", - url=f"https://t.me/{UPDATES_CHANNEL}") - ] + InlineKeyboardButton( + text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}" + ), + InlineKeyboardButton( + text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}" + ), ] - ) - - chat_id = m.chat.id - if len(m.command) < 2: - await m.reply("» give me a live-link/m3u8 url/youtube link to stream.") - else: - if len(m.command)==2: - link = m.text.split(None, 1)[1] - Q = 720 - loser = await m.reply("🔄 **processing stream...**") - elif len(m.command)==3: - op = m.text.split(None, 1)[1] - link = op.split(None, 1)[0] - quality = op.split(None, 1)[1] - if quality == "720" or "480" or "360": - Q = int(quality) - else: + ] + ) + + chat_id = m.chat.id + if len(m.command) < 2: + await m.reply("» give me a live-link/m3u8 url/youtube link to stream.") + else: + if len(m.command) == 2: + link = m.text.split(None, 1)[1] Q = 720 - await m.reply("» __only 720, 480, 360 allowed__ \n💡 **now streaming video in 720p**") - loser = await m.reply("🔄 **processing stream...**") - else: - await m.reply("**/vstream {link} {720/480/360}**") + loser = await m.reply("🔄 **processing stream...**") + elif len(m.command) == 3: + op = m.text.split(None, 1)[1] + link = op.split(None, 1)[0] + quality = op.split(None, 1)[1] + if quality == "720" or "480" or "360": + Q = int(quality) + else: + Q = 720 + await m.reply( + "» __only 720, 480, 360 allowed__ \n💡 **now streaming video in 720p**" + ) + loser = await m.reply("🔄 **processing stream...**") + else: + await m.reply("**/vstream {link} {720/480/360}**") - regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+" - match = re.match(regex,link) - if match: - veez, livelink = await ytdl(link) - else: - livelink = link - veez = 1 + regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+" + match = re.match(regex, link) + if match: + veez, livelink = await ytdl(link) + else: + livelink = link + veez = 1 - if veez==0: - await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") - else: - if chat_id in QUEUE: - pos = add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q) - await loser.delete() - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to the queue**\n\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", - reply_markup=keyboard, - ) - else: - if Q==720: - amaze = HighQualityVideo() - elif Q==480: - amaze = MediumQualityVideo() - elif Q==360: - amaze = LowQualityVideo() - try: - await call_py.join_group_call( - chat_id, - AudioVideoPiped( - livelink, - HighQualityAudio(), - amaze - ), - stream_type=StreamType().pulse_stream, - ) - add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q) - await loser.delete() - await m.reply_photo( - photo=f"{IMG_2}", - caption=f"💡 **[Live stream video]({link}) started.**\n\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, - ) - except Exception as ep: - await m.reply_text(f"🚫 error: `{ep}`") + if veez == 0: + await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") + else: + if chat_id in QUEUE: + pos = add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q) + await loser.delete() + await m.reply_photo( + photo=f"{IMG_1}", + caption=f"💡 **Track added to the queue**\n\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`", + reply_markup=keyboard, + ) + else: + if Q == 720: + amaze = HighQualityVideo() + elif Q == 480: + amaze = MediumQualityVideo() + elif Q == 360: + amaze = LowQualityVideo() + try: + await call_py.join_group_call( + chat_id, + AudioVideoPiped(livelink, HighQualityAudio(), amaze), + stream_type=StreamType().pulse_stream, + ) + add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q) + await loser.delete() + await m.reply_photo( + photo=f"{IMG_2}", + caption=f"💡 **[Live stream video]({link}) started.**\n\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", + reply_markup=keyboard, + ) + except Exception as ep: + await m.reply_text(f"🚫 error: `{ep}`") diff --git a/runtime.txt b/runtime.txt index 2153d1e..fadb070 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.9.7 +python-3.10.0