merge pull request #20 from levina-lab/main

push commit from base
This commit is contained in:
levina 2021-10-31 03:36:17 +07:00 committed by GitHub
commit 485c66999d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 691 additions and 605 deletions

View File

@ -5,4 +5,4 @@ COPY . /py
WORKDIR /py WORKDIR /py
RUN pip3 install -U pip RUN pip3 install -U pip
RUN pip3 install -U -r requirements.txt RUN pip3 install -U -r requirements.txt
CMD python3 -m program CMD ["python3", "main.py"]

View File

@ -1 +1 @@
worker: python3 -m program worker: python3 main.py

View File

@ -22,6 +22,6 @@ SUDO_USERS = list(map(int, getenv("SUDO_USERS").split()))
COMMAND_PREFIXES = list(getenv("COMMAND_PREFIXES", "/ ! .").split()) COMMAND_PREFIXES = list(getenv("COMMAND_PREFIXES", "/ ! .").split())
ALIVE_IMG = getenv("ALIVE_IMG", "https://telegra.ph/file/c83b000f004f01897fe18.png") ALIVE_IMG = getenv("ALIVE_IMG", "https://telegra.ph/file/c83b000f004f01897fe18.png")
DURATION_LIMIT = int(getenv("DURATION_LIMIT", "60")) DURATION_LIMIT = int(getenv("DURATION_LIMIT", "60"))
IMG_1 = getenv("IMG_1", "https://telegra.ph/file/92674c567ef7eb72521d2.png") IMG_1 = getenv("IMG_1", "https://telegra.ph/file/d6f92c979ad96b2031cba.png")
IMG_2 = getenv("IMG_2", "https://telegra.ph/file/9aa0eb8e4703e6a1d94d7.png") IMG_2 = getenv("IMG_2", "https://telegra.ph/file/6213d2673486beca02967.png")
IMG_3 = getenv("IMG_3", "https://telegra.ph/file/84568c753c738d7cfed46.png") IMG_3 = getenv("IMG_3", "https://telegra.ph/file/f02efde766160d3ff52d6.png")

View File

@ -1,5 +1,3 @@
build: build:
docker: docker:
worker: Dockerfile worker: Dockerfile
run:
worker: python3 -m program

18
main.py Normal file
View File

@ -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())

View File

@ -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()

View File

@ -1,12 +1,12 @@
from cache.admins import admins from cache.admins import admins
from driver.filters import command, other_filters from config import BOT_USERNAME, GROUP_SUPPORT, IMG_3, UPDATES_CHANNEL
from pyrogram import Client, filters
from driver.veez import call_py, bot
from driver.queues import QUEUE, clear_queue
from driver.decorators import authorized_users_only 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 driver.utils import skip_current_song, skip_item
from config import BOT_USERNAME, IMG_3, GROUP_SUPPORT, UPDATES_CHANNEL from driver.veez import call_py
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup from pyrogram import Client
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
@Client.on_message(command(["reload", f"reload@{BOT_USERNAME}"]) & other_filters) @Client.on_message(command(["reload", f"reload@{BOT_USERNAME}"]) & other_filters)
@ -31,11 +31,11 @@ async def skip(client, m: Message):
[ [
[ [
InlineKeyboardButton( InlineKeyboardButton(
text="✨ ɢʀᴏᴜᴘ", text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}"
url=f"https://t.me/{GROUP_SUPPORT}"), ),
InlineKeyboardButton( InlineKeyboardButton(
text="🌻 ᴄʜᴀɴɴᴇʟ", text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}"
url=f"https://t.me/{UPDATES_CHANNEL}") ),
] ]
] ]
) )
@ -50,7 +50,7 @@ async def skip(client, m: Message):
else: else:
await m.reply_photo( await m.reply_photo(
photo=f"{IMG_3}", 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, reply_markup=keyboard,
) )
else: else:
@ -71,7 +71,10 @@ async def skip(client, m: Message):
await m.reply(OP) 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 @authorized_users_only
async def stop(client, m: Message): async def stop(client, m: Message):
chat_id = m.chat.id chat_id = m.chat.id
@ -86,29 +89,51 @@ async def stop(client, m: Message):
await m.reply("❌ **nothing in streaming**") 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 @authorized_users_only
async def pause(client, m: Message): async def pause(client, m: Message):
chat_id = m.chat.id chat_id = m.chat.id
if chat_id in QUEUE: if chat_id in QUEUE:
try: try:
await call_py.pause_stream(chat_id) await call_py.pause_stream(chat_id)
await m.reply("⏸ **Track paused.**\n\n• **To resume the stream, use the**\n» /resume command.") await m.reply(
"⏸ **Track paused.**\n\n• **To resume the stream, use the**\n» /resume command."
)
except Exception as e: except Exception as e:
await m.reply(f"🚫 **error:**\n\n`{e}`") await m.reply(f"🚫 **error:**\n\n`{e}`")
else: else:
await m.reply("❌ **nothing in streaming**") 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 @authorized_users_only
async def resume(client, m: Message): async def resume(client, m: Message):
chat_id = m.chat.id chat_id = m.chat.id
if chat_id in QUEUE: if chat_id in QUEUE:
try: try:
await call_py.resume_stream(chat_id) await call_py.resume_stream(chat_id)
await m.reply("▶️ **Track resumed.**\n\n• **To pause the stream, use the**\n» /pause command.") await m.reply(
"▶️ **Track resumed.**\n\n• **To pause the stream, use the**\n» /pause command."
)
except Exception as e: except Exception as e:
await m.reply(f"🚫 **error:**\n\n`{e}`") await m.reply(f"🚫 **error:**\n\n`{e}`")
else: else:
await m.reply("❌ **nothing in streaming**") 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}")

View File

@ -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!** 💡 **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( reply_markup=InlineKeyboardMarkup(
[ [
[ [
@ -58,11 +58,14 @@ async def cbguides(_, query: CallbackQuery):
await query.edit_message_text( await query.edit_message_text(
f"""❓ **Basic Guide for using this bot:** f"""❓ **Basic Guide for using this bot:**
1.) **first, add me to your group.** 1.) **First, add me to your group.**
2.) **then promote me as admin and give all permissions except anonymous admin.** 2.) **Then, promote me as administrator and give all permissions except Anonymous Admin.**
3.) **add @{ASSISTANT_NAME} to your group or type /userbotjoin to invite her.** 3.) **After promoting me, type /reload in group to refresh the admin data.**
4.) **turn on the video chat first before start to play video.** 3.) **Add @{ASSISTANT_NAME} to your group or type /userbotjoin to invite her.**
5.) **all the command list you can see on » 📚 Commands button, find it on start home, tap the » Go Back button below.** 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}** 💡 **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")) @Client.on_callback_query(filters.regex("cbcmds"))
async def cbhelps(_, query: CallbackQuery): async def cbcmds(_, query: CallbackQuery):
await query.edit_message_text( 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 » **press the button below to read the explanation and see the list of available commands !**
» /stream - enter the radio link
» /vplay - play video on video chat __Powered by {BOT_NAME} A.I__""",
» /vstream - for m3u8/live link 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 » /playlist - show you the playlist
» /video (query) - download video from youtube » /video (query) - download video from youtube
» /song (query) - download song from youtube » /song (query) - download song from youtube
» /lyric (query) - scrap the song lyric » /lyric (query) - scrap the song lyric
» /search (query) - search a youtube video link » /search (query) - search a youtube video link
» /queue - show you the queue list (admin only)
» /pause - pause the stream (admin only) » /ping - show the bot ping status
» /resume - resume the stream (admin only) » /uptime - show the bot uptime status
» /skip - switch to next stream (admin only) » /alive - show the bot alive info (in group)
» /stop - stop the streaming (admin only)
» /userbotjoin - invite the userbot to join chat (admin only) __Powered by {BOT_NAME} AI__""",
» /userbotleave - order userbot to leave from group (admin only) reply_markup=InlineKeyboardMarkup(
» /reload - update the admin list (admin only) [[InlineKeyboardButton("🔙 Go Back", callback_data="cbcmds")]]
» /rmw - clean raw files (sudo only) ),
» /rmd - clean downloaded files (sudo only) )
» /leaveall - order userbot leave from all group (sudo only)
@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__""", __Powered by {BOT_NAME} AI__""",
reply_markup=InlineKeyboardMarkup( reply_markup=InlineKeyboardMarkup(
[[InlineKeyboardButton("🔙 Go Back", callback_data="cbstart")]] [[InlineKeyboardButton("🔙 Go Back", callback_data="cbcmds")]]
), ),
) )

View File

@ -2,29 +2,29 @@
# Commit Start Date 20/10/2021 # Commit Start Date 20/10/2021
# Finished On 28/10/2021 # Finished On 28/10/2021
import os
import re
import asyncio import asyncio
from driver.veez import call_py import re
from pytgcalls import StreamType
from config import BOT_USERNAME, GROUP_SUPPORT, IMG_1, IMG_2, UPDATES_CHANNEL
from driver.filters import command, other_filters 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.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 pytgcalls.types.input_stream import AudioPiped
from config import BOT_USERNAME, IMG_1, IMG_2, GROUP_SUPPORT, UPDATES_CHANNEL from youtubesearchpython import VideosSearch
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
def ytsearch(query): def ytsearch(query):
try: try:
search = VideosSearch(query, limit=1) search = VideosSearch(query, limit=1)
for r in search.result()["result"]: for r in search.result()["result"]:
ytid = r['id'] ytid = r["id"]
if len(r['title']) > 34: if len(r["title"]) > 34:
songname = r['title'][:60] + "..." songname = r["title"][:60] + "..."
else: else:
songname = r['title'] songname = r["title"]
url = f"https://www.youtube.com/watch?v={ytid}" url = f"https://www.youtube.com/watch?v={ytid}"
return [songname, url] return [songname, url]
except Exception as e: except Exception as e:
@ -34,33 +34,33 @@ def ytsearch(query):
async def ytdl(link): async def ytdl(link):
proc = await asyncio.create_subprocess_exec( proc = await asyncio.create_subprocess_exec(
'yt-dlp', "yt-dlp",
'-g', "-g",
'-f', "-f",
'bestaudio', "bestaudio",
f'{link}', f"{link}",
stdout=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
) )
stdout, stderr = await proc.communicate() stdout, stderr = await proc.communicate()
if stdout: if stdout:
return 1, stdout.decode().split('\n')[0] return 1, stdout.decode().split("\n")[0]
else: else:
return 0, stderr.decode() return 0, stderr.decode()
@Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters) @Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters)
async def play(client, m: Message): async def play(_, m: Message):
keyboard = InlineKeyboardMarkup( keyboard = InlineKeyboardMarkup(
[ [
[ [
InlineKeyboardButton( InlineKeyboardButton(
text="✨ ɢʀᴏᴜᴘ", text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}"
url=f"https://t.me/{GROUP_SUPPORT}"), ),
InlineKeyboardButton( InlineKeyboardButton(
text="🌻 ᴄʜᴀɴɴᴇʟ", text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}"
url=f"https://t.me/{UPDATES_CHANNEL}") ),
] ]
] ]
) )
@ -96,6 +96,7 @@ async def play(client, m: Message):
stream_type=StreamType().pulse_stream, stream_type=StreamType().pulse_stream,
) )
add_to_queue(chat_id, songname, dl, link, "Audio", 0) add_to_queue(chat_id, songname, dl, link, "Audio", 0)
await suhu.delete()
await m.reply_photo( await m.reply_photo(
photo=f"{IMG_2}", 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()}", caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}",
@ -103,7 +104,56 @@ async def play(client, m: Message):
) )
else: else:
if len(m.command) < 2: if len(m.command) < 2:
await m.reply("» reply to an **audio file** or **give something to search.**") 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: else:
suhu = await m.reply("🔎 **searching...**") suhu = await m.reply("🔎 **searching...**")
query = m.text.split(None, 1)[1] query = m.text.split(None, 1)[1]
@ -144,63 +194,21 @@ async def play(client, m: Message):
except Exception as ep: except Exception as ep:
await m.reply_text(f"🚫 error: `{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}`")
# stream is used for live streaming only # stream is used for live streaming only
@Client.on_message(command(["stream", f"stream@{BOT_USERNAME}"]) & other_filters) @Client.on_message(command(["stream", f"stream@{BOT_USERNAME}"]) & other_filters)
async def stream(client, m: Message): async def stream(_, m: Message):
keyboard = InlineKeyboardMarkup( keyboard = InlineKeyboardMarkup(
[ [
[ [
InlineKeyboardButton( InlineKeyboardButton(
text="✨ ɢʀᴏᴜᴘ", text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}"
url=f"https://t.me/{GROUP_SUPPORT}"), ),
InlineKeyboardButton( InlineKeyboardButton(
text="🌻 ᴄʜᴀɴɴᴇʟ", text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}"
url=f"https://t.me/{UPDATES_CHANNEL}") ),
] ]
] ]
) )

View File

@ -12,7 +12,6 @@ from config import (
UPDATES_CHANNEL, UPDATES_CHANNEL,
) )
from program import __version__ from program import __version__
from driver.decorators import sudo_users_only
from driver.filters import command, other_filters from driver.filters import command, other_filters
from pyrogram import Client, filters from pyrogram import Client, filters
from pyrogram import __version__ as pyrover 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!** 💡 **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( reply_markup=InlineKeyboardMarkup(
[ [
@ -71,7 +70,7 @@ async def start_(client: Client, message: Message):
[InlineKeyboardButton("❓ Basic Guide", callback_data="cbhowtouse")], [InlineKeyboardButton("❓ Basic Guide", callback_data="cbhowtouse")],
[ [
InlineKeyboardButton("📚 Commands", callback_data="cbcmds"), InlineKeyboardButton("📚 Commands", callback_data="cbcmds"),
InlineKeyboardButton("💝 Donate", url=f"https://t.me/{OWNER_NAME}"), InlineKeyboardButton("❤️ Donate", url=f"https://t.me/{OWNER_NAME}"),
], ],
[ [
InlineKeyboardButton( InlineKeyboardButton(
@ -129,7 +128,6 @@ async def ping_pong(client: Client, message: Message):
@Client.on_message(command(["uptime", f"uptime@{BOT_USERNAME}"]) & ~filters.edited) @Client.on_message(command(["uptime", f"uptime@{BOT_USERNAME}"]) & ~filters.edited)
@sudo_users_only
async def get_uptime(client: Client, message: Message): async def get_uptime(client: Client, message: Message):
current_time = datetime.utcnow() current_time = datetime.utcnow()
uptime_sec = (current_time - START_TIME).total_seconds() uptime_sec = (current_time - START_TIME).total_seconds()

View File

@ -2,31 +2,35 @@
# Commit Start Date 20/10/2021 # Commit Start Date 20/10/2021
# Finished On 28/10/2021 # Finished On 28/10/2021
import os
import re
import asyncio import asyncio
from driver.veez import call_py import re
from pytgcalls import StreamType
from pyrogram import Client, filters from config import BOT_USERNAME, GROUP_SUPPORT, IMG_1, IMG_2, UPDATES_CHANNEL
from driver.filters import command, other_filters from driver.filters import command, other_filters
from youtubesearchpython import VideosSearch
from driver.queues import QUEUE, add_to_queue 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 pytgcalls.types.input_stream import AudioVideoPiped
from config import BOT_USERNAME, IMG_1, IMG_2, GROUP_SUPPORT, UPDATES_CHANNEL from pytgcalls.types.input_stream.quality import (
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup HighQualityAudio,
from pytgcalls.types.input_stream.quality import HighQualityAudio, MediumQualityAudio HighQualityVideo,
from pytgcalls.types.input_stream.quality import HighQualityVideo, MediumQualityVideo, LowQualityVideo LowQualityVideo,
MediumQualityVideo,
)
from youtubesearchpython import VideosSearch
def ytsearch(query): def ytsearch(query):
try: try:
search = VideosSearch(query, limit=1) search = VideosSearch(query, limit=1)
for r in search.result()["result"]: for r in search.result()["result"]:
ytid = r['id'] ytid = r["id"]
if len(r['title']) > 34: if len(r["title"]) > 34:
songname = r['title'][:60] + "..." songname = r["title"][:60] + "..."
else: else:
songname = r['title'] songname = r["title"]
url = f"https://www.youtube.com/watch?v={ytid}" url = f"https://www.youtube.com/watch?v={ytid}"
return [songname, url] return [songname, url]
except Exception as e: except Exception as e:
@ -36,17 +40,17 @@ def ytsearch(query):
async def ytdl(link): async def ytdl(link):
proc = await asyncio.create_subprocess_exec( proc = await asyncio.create_subprocess_exec(
'yt-dlp', "yt-dlp",
'-g', "-g",
'-f', "-f",
'best[height<=?720][width<=?1280]', "best[height<=?720][width<=?1280]",
f'{link}', f"{link}",
stdout=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
) )
stdout, stderr = await proc.communicate() stdout, stderr = await proc.communicate()
if stdout: if stdout:
return 1, stdout.decode().split('\n')[0] return 1, stdout.decode().split("\n")[0]
else: else:
return 0, stderr.decode() return 0, stderr.decode()
@ -58,11 +62,11 @@ async def vplay(client, m: Message):
[ [
[ [
InlineKeyboardButton( InlineKeyboardButton(
text="✨ ɢʀᴏᴜᴘ", text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}"
url=f"https://t.me/{GROUP_SUPPORT}"), ),
InlineKeyboardButton( InlineKeyboardButton(
text="🌻 ᴄʜᴀɴɴᴇʟ", text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}"
url=f"https://t.me/{UPDATES_CHANNEL}") ),
] ]
] ]
) )
@ -82,7 +86,9 @@ async def vplay(client, m: Message):
Q = int(pq) Q = int(pq)
else: else:
Q = 720 Q = 720
await loser.edit("» __only 720, 480, 360 allowed__ \n💡 **now streaming video in 720p**") await loser.edit(
"» __only 720, 480, 360 allowed__ \n💡 **now streaming video in 720p**"
)
if replied.video: if replied.video:
songname = replied.video.file_name[:60] + "..." songname = replied.video.file_name[:60] + "..."
@ -106,11 +112,7 @@ async def vplay(client, m: Message):
amaze = LowQualityVideo() amaze = LowQualityVideo()
await call_py.join_group_call( await call_py.join_group_call(
chat_id, chat_id,
AudioVideoPiped( AudioVideoPiped(dl, HighQualityAudio(), amaze),
dl,
HighQualityAudio(),
amaze
),
stream_type=StreamType().pulse_stream, stream_type=StreamType().pulse_stream,
) )
add_to_queue(chat_id, songname, dl, link, "Video", Q) add_to_queue(chat_id, songname, dl, link, "Video", Q)
@ -122,7 +124,9 @@ async def vplay(client, m: Message):
) )
else: else:
if len(m.command) < 2: if len(m.command) < 2:
await m.reply("» reply to an **video file** or **give something to search.**") await m.reply(
"» reply to an **video file** or **give something to search.**"
)
else: else:
loser = await m.reply("🔎 **searching...**") loser = await m.reply("🔎 **searching...**")
query = m.text.split(None, 1)[1] query = m.text.split(None, 1)[1]
@ -139,7 +143,9 @@ async def vplay(client, m: Message):
await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`")
else: else:
if chat_id in QUEUE: if chat_id in QUEUE:
pos = add_to_queue(chat_id, songname, ytlink, url, "Video", Q) pos = add_to_queue(
chat_id, songname, ytlink, url, "Video", Q
)
await loser.delete() await loser.delete()
await m.reply_photo( await m.reply_photo(
photo=f"{IMG_1}", photo=f"{IMG_1}",
@ -150,11 +156,7 @@ async def vplay(client, m: Message):
try: try:
await call_py.join_group_call( await call_py.join_group_call(
chat_id, chat_id,
AudioVideoPiped( AudioVideoPiped(ytlink, HighQualityAudio(), amaze),
ytlink,
HighQualityAudio(),
amaze
),
stream_type=StreamType().pulse_stream, stream_type=StreamType().pulse_stream,
) )
add_to_queue(chat_id, songname, ytlink, url, "Video", Q) add_to_queue(chat_id, songname, ytlink, url, "Video", Q)
@ -169,7 +171,9 @@ async def vplay(client, m: Message):
else: else:
if len(m.command) < 2: if len(m.command) < 2:
await m.reply("» reply to an **video file** or **give something to search.**") await m.reply(
"» reply to an **video file** or **give something to search.**"
)
else: else:
loser = await m.reply("🔎 **searching...**") loser = await m.reply("🔎 **searching...**")
query = m.text.split(None, 1)[1] query = m.text.split(None, 1)[1]
@ -197,11 +201,7 @@ async def vplay(client, m: Message):
try: try:
await call_py.join_group_call( await call_py.join_group_call(
chat_id, chat_id,
AudioVideoPiped( AudioVideoPiped(ytlink, HighQualityAudio(), amaze),
ytlink,
HighQualityAudio(),
amaze
),
stream_type=StreamType().pulse_stream, stream_type=StreamType().pulse_stream,
) )
add_to_queue(chat_id, songname, ytlink, url, "Video", Q) add_to_queue(chat_id, songname, ytlink, url, "Video", Q)
@ -222,11 +222,11 @@ async def vstream(client, m: Message):
[ [
[ [
InlineKeyboardButton( InlineKeyboardButton(
text="✨ ɢʀᴏᴜᴘ", text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}"
url=f"https://t.me/{GROUP_SUPPORT}"), ),
InlineKeyboardButton( InlineKeyboardButton(
text="🌻 ᴄʜᴀɴɴᴇʟ", text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}"
url=f"https://t.me/{UPDATES_CHANNEL}") ),
] ]
] ]
) )
@ -247,7 +247,9 @@ async def vstream(client, m: Message):
Q = int(quality) Q = int(quality)
else: else:
Q = 720 Q = 720
await m.reply("» __only 720, 480, 360 allowed__ \n💡 **now streaming video in 720p**") await m.reply(
"» __only 720, 480, 360 allowed__ \n💡 **now streaming video in 720p**"
)
loser = await m.reply("🔄 **processing stream...**") loser = await m.reply("🔄 **processing stream...**")
else: else:
await m.reply("**/vstream {link} {720/480/360}**") await m.reply("**/vstream {link} {720/480/360}**")
@ -281,11 +283,7 @@ async def vstream(client, m: Message):
try: try:
await call_py.join_group_call( await call_py.join_group_call(
chat_id, chat_id,
AudioVideoPiped( AudioVideoPiped(livelink, HighQualityAudio(), amaze),
livelink,
HighQualityAudio(),
amaze
),
stream_type=StreamType().pulse_stream, stream_type=StreamType().pulse_stream,
) )
add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q) add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q)

View File

@ -1 +1 @@
python-3.9.7 python-3.10.0