From 42ae531c0bb8b477140f08b8dcd33c87fc32ecde Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 01:47:52 +0700 Subject: [PATCH 01/29] Create main.py --- main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 main.py 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()) From 8ed427e449793e6b1c13defd76025316a63ebfc5 Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 01:48:23 +0700 Subject: [PATCH 02/29] Delete __main__.py --- program/__main__.py | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 program/__main__.py 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() From 663f948e3dc85171d6522a4870a6d6ad8e7a543d Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 01:55:54 +0700 Subject: [PATCH 03/29] Update admins.py --- program/admins.py | 167 ++++++++++++++++++++++++---------------------- 1 file changed, 89 insertions(+), 78 deletions(-) diff --git a/program/admins.py b/program/admins.py index d8d57ab..1458ccb 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,100 @@ 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🎧 **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**") From afae1dad87bf6baa4e088e55c8e06fd188b24e62 Mon Sep 17 00:00:00 2001 From: Hunter XDD <85411336+Hunter-XDD@users.noreply.github.com> Date: Sat, 30 Oct 2021 00:27:32 +0530 Subject: [PATCH 04/29] use await --- program/__main__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/program/__main__.py b/program/__main__.py index 3c4893b..5db889a 100644 --- a/program/__main__.py +++ b/program/__main__.py @@ -5,9 +5,9 @@ from pytgcalls import idle as engine from driver.veez import bot, call_py from program import __version__ -bot.start() +await bot.start() print(f"program v{__version__} started !") -call_py.start() +await call_py.start() print("program client started !") -engine() -idle() +await engine() +await idle() From ca7d728f2f9a056a33e183c8257f3b0ccd2e0879 Mon Sep 17 00:00:00 2001 From: Hunter XDD <85411336+Hunter-XDD@users.noreply.github.com> Date: Sat, 30 Oct 2021 00:28:25 +0530 Subject: [PATCH 05/29] none --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From ad0bb7868d52fb3e3d31de679b4de6028d9b3f52 Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 02:01:26 +0700 Subject: [PATCH 06/29] Update video.py --- program/video.py | 516 +++++++++++++++++++++++------------------------ 1 file changed, 257 insertions(+), 259 deletions(-) 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}`") From c139afea6d32ad4ebc55a3f97267b9f7a4ba163a Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 02:10:51 +0700 Subject: [PATCH 07/29] Update Dockerfile --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f2a774..2e61e51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM nikolaik/python-nodejs:python3.10-nodejs17 -RUN apt-get update && apt-get upgrade -y -RUN apt-get install ffmpeg -y +RUN apt update && apt upgrade -y +RUN apt install -y ffmpeg python3-pip COPY . /py WORKDIR /py RUN pip3 install -U pip RUN pip3 install -U -r requirements.txt -CMD python3 -m program +CMD ["python3", "main.py"] From 4ee74deefd5f3c5f9cf32e1fbbee0caad6b835d4 Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 02:12:04 +0700 Subject: [PATCH 08/29] Update heroku.yml --- heroku.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 From 6d369cbc0cf75982222681753d60e2991289b638 Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 02:12:38 +0700 Subject: [PATCH 09/29] Update Procfile --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 1bb71de..eb131d6 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -worker: python3 -m program +worker: python3 main.py From e1a02c3a0cd716c75298d7fb5ccf5004c03ed88c Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 02:19:55 +0700 Subject: [PATCH 10/29] no --- program/__main__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/program/__main__.py b/program/__main__.py index 5db889a..3c4893b 100644 --- a/program/__main__.py +++ b/program/__main__.py @@ -5,9 +5,9 @@ from pytgcalls import idle as engine from driver.veez import bot, call_py from program import __version__ -await bot.start() +bot.start() print(f"program v{__version__} started !") -await call_py.start() +call_py.start() print("program client started !") -await engine() -await idle() +engine() +idle() From 60e4cfee9cda59392855ffb9ca78d9363b3d4292 Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 02:49:37 +0700 Subject: [PATCH 11/29] DeprecationWarning --- main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 02df684..c85d35f 100644 --- a/main.py +++ b/main.py @@ -14,5 +14,6 @@ async def mulai_bot(): await bot.stop() -loop = asyncio.get_event_loop() +loop = asyncio.new_event_loop() +asyncio.set_event_loop(loop) loop.run_until_complete(mulai_bot()) From da45831fcd0834e0d4db23e7b729d857c28d1f0b Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 03:19:02 +0700 Subject: [PATCH 12/29] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2e61e51..72db4f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nikolaik/python-nodejs:python3.10-nodejs17 +FROM nikolaik/python-nodejs:python3.9-nodejs17 RUN apt update && apt upgrade -y RUN apt install -y ffmpeg python3-pip COPY . /py From 0a13d2b516d3f6cc87bb2beebde2eff590054e46 Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 03:19:54 +0700 Subject: [PATCH 13/29] wtf --- main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.py b/main.py index c85d35f..02df684 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,5 @@ async def mulai_bot(): await bot.stop() -loop = asyncio.new_event_loop() -asyncio.set_event_loop(loop) +loop = asyncio.get_event_loop() loop.run_until_complete(mulai_bot()) From 617af04c04df485c57be4327da7572928df5235b Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 03:20:26 +0700 Subject: [PATCH 14/29] Update runtime.txt --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.txt b/runtime.txt index fadb070..2153d1e 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.10.0 +python-3.9.7 From 98ae3ce740aafad01cf659e43548f5cee622561e Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 03:24:14 +0700 Subject: [PATCH 15/29] Update music.py ok --- program/music.py | 440 ++++++++++++++++++++++++----------------------- 1 file changed, 224 insertions(+), 216 deletions(-) diff --git a/program/music.py b/program/music.py index 618ee4b..1bb3977 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( + + 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 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"❌ 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_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...**") - 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}`") From 15d1025fda9fa2a4879ec2195f256a417615b018 Mon Sep 17 00:00:00 2001 From: Tofik Denianto <77754555+tofikdn@users.noreply.github.com> Date: Sat, 30 Oct 2021 04:01:56 +0700 Subject: [PATCH 16/29] Update music.py --- program/music.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/program/music.py b/program/music.py index 1bb3977..a605c5c 100644 --- a/program/music.py +++ b/program/music.py @@ -50,7 +50,7 @@ async def ytdl(link): @Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters) -async def play(client, m: Message): +async def play(_, m: Message): keyboard = InlineKeyboardMarkup( [ @@ -96,6 +96,7 @@ async def play(client, m: Message): 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()}", @@ -196,9 +197,8 @@ async def play(client, m: Message): # stream is used for live streaming only - @Client.on_message(command(["stream", f"stream@{BOT_USERNAME}"]) & other_filters) -async def stream(client, m: Message): +async def stream(_, m: Message): keyboard = InlineKeyboardMarkup( [ From acb6b1e556ba8fb037fca57d2b83bbc42499dcf3 Mon Sep 17 00:00:00 2001 From: Hunter XDD <85411336+Hunter-XDD@users.noreply.github.com> Date: Sat, 30 Oct 2021 09:56:10 +0530 Subject: [PATCH 17/29] None --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 72db4f2..21f4a4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM nikolaik/python-nodejs:python3.9-nodejs17 RUN apt update && apt upgrade -y -RUN apt install -y ffmpeg python3-pip +RUN apt install -y ffmpeg COPY . /py WORKDIR /py RUN pip3 install -U pip From 2540fbc759f4f56c72fd311194ee7d6d98c9dd97 Mon Sep 17 00:00:00 2001 From: Hunter XDD <85411336+Hunter-XDD@users.noreply.github.com> Date: Sat, 30 Oct 2021 09:58:00 +0530 Subject: [PATCH 18/29] Now okay --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 21f4a4b..003422c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM nikolaik/python-nodejs:python3.9-nodejs17 -RUN apt update && apt upgrade -y -RUN apt install -y ffmpeg +RUN apt-get update && apt-get upgrade -y +RUN apt-get install ffmpeg -y COPY . /py WORKDIR /py RUN pip3 install -U pip RUN pip3 install -U -r requirements.txt -CMD ["python3", "main.py"] +CMD ["python3", "-m", "program"] From d614702beb7214477ee13576cdea8100f1ab7f81 Mon Sep 17 00:00:00 2001 From: Hunter XDD <85411336+Hunter-XDD@users.noreply.github.com> Date: Sat, 30 Oct 2021 09:58:51 +0530 Subject: [PATCH 19/29] Umm --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 692680410610a271efb4d78c720307deafb5598a Mon Sep 17 00:00:00 2001 From: Hunter XDD <85411336+Hunter-XDD@users.noreply.github.com> Date: Sat, 30 Oct 2021 09:59:15 +0530 Subject: [PATCH 20/29] Sad --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 003422c..f6cd024 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nikolaik/python-nodejs:python3.9-nodejs17 +FROM nikolaik/python-nodejs:python3.10-nodejs17 RUN apt-get update && apt-get upgrade -y RUN apt-get install ffmpeg -y COPY . /py From c94de6bb4f641585fabd032e3baa8ee7c58d36f5 Mon Sep 17 00:00:00 2001 From: Hunter XDD <85411336+Hunter-XDD@users.noreply.github.com> Date: Sat, 30 Oct 2021 10:01:39 +0530 Subject: [PATCH 21/29] Umm --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f6cd024..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"] From e179800707f47f8b37b167652f2878addf39dbfc Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 30 Oct 2021 17:37:18 +0700 Subject: [PATCH 22/29] change --- config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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") From 6438bc08555a9587b97254c364b8753e7c09f5dd Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 30 Oct 2021 17:39:17 +0700 Subject: [PATCH 23/29] nine --- program/admins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/admins.py b/program/admins.py index 1458ccb..45f6744 100644 --- a/program/admins.py +++ b/program/admins.py @@ -50,7 +50,7 @@ async def skip(client, m: Message): 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()}", + 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: From 039ce19d6080fa138bdad667e22a6c88fe432c53 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 30 Oct 2021 18:12:58 +0700 Subject: [PATCH 24/29] none --- program/music.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/music.py b/program/music.py index a605c5c..180bcbc 100644 --- a/program/music.py +++ b/program/music.py @@ -165,7 +165,7 @@ async def play(_, m: Message): url = search[1] veez, ytlink = await ytdl(url) if veez == 0: - await suhu.edit(f"❌ youtube-dl issues detected\n\n» `{ytlink}`") + 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) From 4afbeea2447fd53b9122dacb9f69903afd5c5dd1 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 30 Oct 2021 18:30:01 +0700 Subject: [PATCH 25/29] something --- program/admins.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/program/admins.py b/program/admins.py index 45f6744..a53afc8 100644 --- a/program/admins.py +++ b/program/admins.py @@ -123,3 +123,17 @@ async def resume(client, m: Message): await m.reply(f"🚫 **error:**\n\n`{e}`") else: await m.reply("❌ **nothing in streaming**") + + +@Client.on_message( + command(["volume", f"volume@{BOT_USERNAME}"]) & 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}") From a580836c7b6b2bfcea6fff292898595ca7b8d000 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 30 Oct 2021 19:55:39 +0700 Subject: [PATCH 26/29] more details --- program/callback.py | 100 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 77 insertions(+), 23 deletions(-) diff --git a/program/callback.py b/program/callback.py index 7031c7d..c23754d 100644 --- a/program/callback.py +++ b/program/callback.py @@ -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")]] ), ) From 41d15193e3c05a48b1391de4d1b001bd37560d9f Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 30 Oct 2021 19:56:46 +0700 Subject: [PATCH 27/29] aliases --- program/admins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/admins.py b/program/admins.py index a53afc8..7759cee 100644 --- a/program/admins.py +++ b/program/admins.py @@ -126,7 +126,7 @@ async def resume(client, m: Message): @Client.on_message( - command(["volume", f"volume@{BOT_USERNAME}"]) & other_filters + command(["volume", f"volume@{BOT_USERNAME}", "vol"]) & other_filters ) @authorized_users_only async def change_volume(client, m: Message): From 1b3431d7c5d22bb35be8fced81c17f65267334ff Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 30 Oct 2021 19:58:17 +0700 Subject: [PATCH 28/29] none --- program/start.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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() From 79dde61eb44a5418f9fa4d5cd8b73d3eecd33334 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 30 Oct 2021 20:17:50 +0700 Subject: [PATCH 29/29] none --- program/callback.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/callback.py b/program/callback.py index c23754d..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( [ [