rm last
This commit is contained in:
parent
3e89186b95
commit
15a17ea54f
@ -1 +0,0 @@
|
|||||||
__version__ = "0.6.2"
|
|
@ -1,272 +0,0 @@
|
|||||||
from cache.admins import admins
|
|
||||||
from driver.veez import call_py, bot
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from driver.queues import QUEUE, clear_queue
|
|
||||||
from driver.filters import command, other_filters
|
|
||||||
from driver.decorators import authorized_users_only
|
|
||||||
from driver.utils import skip_current_song, skip_item
|
|
||||||
from program.utils.inline import stream_markup, close_mark, back_mark
|
|
||||||
from config import BOT_USERNAME, GROUP_SUPPORT, IMG_3, UPDATES_CHANNEL
|
|
||||||
from pyrogram.types import (
|
|
||||||
CallbackQuery,
|
|
||||||
InlineKeyboardButton,
|
|
||||||
InlineKeyboardMarkup,
|
|
||||||
Message,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["reload", f"reload@{BOT_USERNAME}"]) & other_filters)
|
|
||||||
@authorized_users_only
|
|
||||||
async def update_admin(client, message):
|
|
||||||
global admins
|
|
||||||
new_admins = []
|
|
||||||
new_ads = await client.get_chat_members(message.chat.id, filter="administrators")
|
|
||||||
for u in new_ads:
|
|
||||||
new_admins.append(u.user.id)
|
|
||||||
admins[message.chat.id] = new_admins
|
|
||||||
await message.reply_text(
|
|
||||||
"✅ Bot **reloaded correctly !**\n✅ **Admin list** has **updated !**"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["skip", f"skip@{BOT_USERNAME}", "vskip"]) & other_filters)
|
|
||||||
@authorized_users_only
|
|
||||||
async def skip(client, m: Message):
|
|
||||||
await m.delete()
|
|
||||||
user_id = m.from_user.id
|
|
||||||
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**")
|
|
||||||
elif op == 2:
|
|
||||||
await m.reply("🗑️ **Clearing the Queues**\n\n**• userbot leaving voice chat**")
|
|
||||||
else:
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
await m.send_photo(
|
|
||||||
chat_id,
|
|
||||||
photo=f"{IMG_3}",
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"⏭ **Skipped to the next track.**\n\n🗂 **Name:** [{op[0]}]({op[1]})\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
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
|
|
||||||
)
|
|
||||||
@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("✅ The userbot has disconnected from the video chat.")
|
|
||||||
except Exception as e:
|
|
||||||
await m.reply(f"🚫 **error:**\n\n`{e}`")
|
|
||||||
else:
|
|
||||||
await m.reply("❌ **nothing is streaming**")
|
|
||||||
|
|
||||||
|
|
||||||
@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**")
|
|
||||||
|
|
||||||
|
|
||||||
@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**")
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
|
||||||
command(["mute", f"mute@{BOT_USERNAME}", "vmute"]) & other_filters
|
|
||||||
)
|
|
||||||
@authorized_users_only
|
|
||||||
async def mute(client, m: Message):
|
|
||||||
chat_id = m.chat.id
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
try:
|
|
||||||
await call_py.mute_stream(chat_id)
|
|
||||||
await m.reply(
|
|
||||||
"🔇 **Userbot muted.**\n\n• **To unmute the userbot, use the**\n» /unmute command."
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await m.reply(f"🚫 **error:**\n\n`{e}`")
|
|
||||||
else:
|
|
||||||
await m.reply("❌ **nothing in streaming**")
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
|
||||||
command(["unmute", f"unmute@{BOT_USERNAME}", "vunmute"]) & other_filters
|
|
||||||
)
|
|
||||||
@authorized_users_only
|
|
||||||
async def unmute(client, m: Message):
|
|
||||||
chat_id = m.chat.id
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
try:
|
|
||||||
await call_py.unmute_stream(chat_id)
|
|
||||||
await m.reply(
|
|
||||||
"🔊 **Userbot unmuted.**\n\n• **To mute the userbot, use the**\n» /mute command."
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await m.reply(f"🚫 **error:**\n\n`{e}`")
|
|
||||||
else:
|
|
||||||
await m.reply("❌ **nothing in streaming**")
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cbpause"))
|
|
||||||
async def cbpause(_, query: CallbackQuery):
|
|
||||||
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
|
|
||||||
chat_id = query.message.chat.id
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
try:
|
|
||||||
await call_py.pause_stream(chat_id)
|
|
||||||
await query.answer("streaming paused")
|
|
||||||
await query.edit_message_text(
|
|
||||||
"⏸ the streaming has paused", reply_markup=back_mark
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
|
||||||
else:
|
|
||||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cbresume"))
|
|
||||||
async def cbresume(_, query: CallbackQuery):
|
|
||||||
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
|
|
||||||
chat_id = query.message.chat.id
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
try:
|
|
||||||
await call_py.resume_stream(chat_id)
|
|
||||||
await query.answer("streaming resumed")
|
|
||||||
await query.edit_message_text(
|
|
||||||
"▶️ the streaming has resumed", reply_markup=back_mark
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
|
||||||
else:
|
|
||||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cbstop"))
|
|
||||||
async def cbstop(_, query: CallbackQuery):
|
|
||||||
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
|
|
||||||
chat_id = query.message.chat.id
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
try:
|
|
||||||
await call_py.leave_group_call(chat_id)
|
|
||||||
clear_queue(chat_id)
|
|
||||||
await query.edit_message_text("✅ **this streaming has ended**", reply_markup=close_mark)
|
|
||||||
except Exception as e:
|
|
||||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
|
||||||
else:
|
|
||||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cbmute"))
|
|
||||||
async def cbmute(_, query: CallbackQuery):
|
|
||||||
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
|
|
||||||
chat_id = query.message.chat.id
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
try:
|
|
||||||
await call_py.mute_stream(chat_id)
|
|
||||||
await query.answer("streaming muted")
|
|
||||||
await query.edit_message_text(
|
|
||||||
"🔇 userbot succesfully muted", reply_markup=back_mark
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
|
||||||
else:
|
|
||||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cbunmute"))
|
|
||||||
async def cbunmute(_, query: CallbackQuery):
|
|
||||||
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
|
|
||||||
chat_id = query.message.chat.id
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
try:
|
|
||||||
await call_py.unmute_stream(chat_id)
|
|
||||||
await query.answer("streaming unmuted")
|
|
||||||
await query.edit_message_text(
|
|
||||||
"🔊 userbot succesfully unmuted", reply_markup=back_mark
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
|
||||||
else:
|
|
||||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
|
||||||
|
|
||||||
|
|
||||||
@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
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
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}`")
|
|
||||||
else:
|
|
||||||
await m.reply("❌ **nothing in streaming**")
|
|
@ -1,199 +0,0 @@
|
|||||||
# Copyright (C) 2021 By VeezMusicProject
|
|
||||||
|
|
||||||
from driver.queues import QUEUE
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from program.utils.inline import menu_markup
|
|
||||||
from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup
|
|
||||||
from config import (
|
|
||||||
ASSISTANT_NAME,
|
|
||||||
BOT_NAME,
|
|
||||||
BOT_USERNAME,
|
|
||||||
GROUP_SUPPORT,
|
|
||||||
OWNER_NAME,
|
|
||||||
UPDATES_CHANNEL,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cbstart"))
|
|
||||||
async def cbstart(_, query: CallbackQuery):
|
|
||||||
await query.answer("home start")
|
|
||||||
await query.edit_message_text(
|
|
||||||
f"""✨ **Welcome [{query.message.chat.first_name}](tg://user?id={query.message.chat.id}) !**\n
|
|
||||||
💭 **[{BOT_NAME}](https://t.me/{BOT_USERNAME}) allows you to play music and video on groups through the new Telegram's video chats!**
|
|
||||||
|
|
||||||
💡 **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!**""",
|
|
||||||
reply_markup=InlineKeyboardMarkup(
|
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"➕ Add me to your Group ➕",
|
|
||||||
url=f"https://t.me/{BOT_USERNAME}?startgroup=true",
|
|
||||||
)
|
|
||||||
],
|
|
||||||
[InlineKeyboardButton("❓ Basic Guide", callback_data="cbhowtouse")],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton("📚 Commands", callback_data="cbcmds"),
|
|
||||||
InlineKeyboardButton("❤ Donate", url=f"https://t.me/{OWNER_NAME}"),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"👥 Official Group", url=f"https://t.me/{GROUP_SUPPORT}"
|
|
||||||
),
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"📣 Official Channel", url=f"https://t.me/{UPDATES_CHANNEL}"
|
|
||||||
),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"🌐 Source Code", url="https://github.com/levina-lab/video-stream"
|
|
||||||
)
|
|
||||||
],
|
|
||||||
]
|
|
||||||
),
|
|
||||||
disable_web_page_preview=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cbhowtouse"))
|
|
||||||
async def cbguides(_, query: CallbackQuery):
|
|
||||||
await query.answer("user guide")
|
|
||||||
await query.edit_message_text(
|
|
||||||
f"""❓ How to use this Bot ?, read the Guide below !
|
|
||||||
|
|
||||||
1.) First, add this bot to your Group.
|
|
||||||
2.) Then, promote this bot as administrator on the Group also give all permissions except Anonymous admin.
|
|
||||||
3.) After promoting this bot, type /reload in Group to update the admin data.
|
|
||||||
3.) Invite @{ASSISTANT_NAME} to your group or type /userbotjoin to invite her (unfortunately the userbot will joined by itself when you type `/play (song name)` or `/vplay (song name)`).
|
|
||||||
4.) Turn on/Start the video chat first before start to play video/music.
|
|
||||||
|
|
||||||
`- END, EVERYTHING HAS BEEN SETUP -`
|
|
||||||
|
|
||||||
📌 If the userbot not joined to video chat, make sure if the video chat already turned on and the userbot in the chat.
|
|
||||||
|
|
||||||
💡 If you have a follow-up questions about this bot, you can tell it on my support chat here: @{GROUP_SUPPORT}.""",
|
|
||||||
reply_markup=InlineKeyboardMarkup(
|
|
||||||
[[InlineKeyboardButton("🔙 Go Back", callback_data="cbstart")]]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cbcmds"))
|
|
||||||
async def cbcmds(_, query: CallbackQuery):
|
|
||||||
await query.answer("commands menu")
|
|
||||||
await query.edit_message_text(
|
|
||||||
f"""✨ **Hello [{query.message.chat.first_name}](tg://user?id={query.message.chat.id}) !**
|
|
||||||
|
|
||||||
» **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.answer("basic commands")
|
|
||||||
await query.edit_message_text(
|
|
||||||
f"""🏮 here is the basic commands:
|
|
||||||
|
|
||||||
» /play (song name/link) - play music on video chat
|
|
||||||
» /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
|
|
||||||
|
|
||||||
» /ping - show the bot ping status
|
|
||||||
» /speedtest - run the bot server speedtest
|
|
||||||
» /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.answer("admin commands")
|
|
||||||
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
|
|
||||||
» /vmute - mute the userbot on voice chat
|
|
||||||
» /vunmute - unmute the userbot on voice chat
|
|
||||||
» /volume `1-200` - adjust the volume of music (userbot must be admin)
|
|
||||||
» /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.answer("sudo commands")
|
|
||||||
await query.edit_message_text(
|
|
||||||
f"""🏮 here is the sudo commands:
|
|
||||||
|
|
||||||
» /rmw - clean all raw files
|
|
||||||
» /rmd - clean all downloaded files
|
|
||||||
» /sysinfo - show the system information
|
|
||||||
» /update - update your bot to latest version
|
|
||||||
» /restart - restart your bot
|
|
||||||
» /leaveall - order userbot to leave from all group
|
|
||||||
|
|
||||||
⚡ __Powered by {BOT_NAME} AI__""",
|
|
||||||
reply_markup=InlineKeyboardMarkup(
|
|
||||||
[[InlineKeyboardButton("🔙 Go Back", callback_data="cbcmds")]]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cbmenu"))
|
|
||||||
async def cbmenu(_, query: CallbackQuery):
|
|
||||||
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
|
|
||||||
chat_id = query.message.chat.id
|
|
||||||
user_id = query.message.from_user.id
|
|
||||||
buttons = menu_markup(user_id)
|
|
||||||
chat = query.message.chat.title
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
await query.edit_message_text(
|
|
||||||
f"⚙️ **Settings of** {chat}\n\n⏸ : pause stream\n▶️ : resume stream\n🔇 : mute userbot\n🔊 : unmute userbot\n⏹ : stop stream",
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("cls"))
|
|
||||||
async def close(_, query: CallbackQuery):
|
|
||||||
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
|
|
||||||
await query.message.delete()
|
|
@ -1,170 +0,0 @@
|
|||||||
# Copyright (C) 2021 By Veez Music-Project
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import math
|
|
||||||
import time
|
|
||||||
import asyncio
|
|
||||||
import lyricsgenius
|
|
||||||
from random import randint
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
import aiofiles
|
|
||||||
import aiohttp
|
|
||||||
import requests
|
|
||||||
import wget
|
|
||||||
import yt_dlp
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from pyrogram.errors import FloodWait, MessageNotModified
|
|
||||||
from pyrogram.types import Message
|
|
||||||
from youtube_search import YoutubeSearch
|
|
||||||
from youtubesearchpython import VideosSearch
|
|
||||||
from yt_dlp import YoutubeDL
|
|
||||||
|
|
||||||
from config import BOT_USERNAME as bn
|
|
||||||
from driver.decorators import humanbytes
|
|
||||||
from driver.filters import command, other_filters
|
|
||||||
|
|
||||||
|
|
||||||
ydl_opts = {
|
|
||||||
'format': 'best',
|
|
||||||
'keepvideo': True,
|
|
||||||
'prefer_ffmpeg': False,
|
|
||||||
'geo_bypass': True,
|
|
||||||
'outtmpl': '%(title)s.%(ext)s',
|
|
||||||
'quite': True
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["song", f"song@{bn}"]) & ~filters.edited)
|
|
||||||
def song(_, message):
|
|
||||||
query = " ".join(message.command[1:])
|
|
||||||
m = message.reply("🔎 finding song...")
|
|
||||||
ydl_ops = {"format": "bestaudio[ext=m4a]"}
|
|
||||||
try:
|
|
||||||
results = YoutubeSearch(query, max_results=1).to_dict()
|
|
||||||
link = f"https://youtube.com{results[0]['url_suffix']}"
|
|
||||||
title = results[0]["title"][:40]
|
|
||||||
thumbnail = results[0]["thumbnails"][0]
|
|
||||||
thumb_name = f"{title}.jpg"
|
|
||||||
thumb = requests.get(thumbnail, allow_redirects=True)
|
|
||||||
open(thumb_name, "wb").write(thumb.content)
|
|
||||||
duration = results[0]["duration"]
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
m.edit("❌ song not found.\n\nplease give a valid song name.")
|
|
||||||
print(str(e))
|
|
||||||
return
|
|
||||||
m.edit("📥 downloading file...")
|
|
||||||
try:
|
|
||||||
with yt_dlp.YoutubeDL(ydl_ops) as ydl:
|
|
||||||
info_dict = ydl.extract_info(link, download=False)
|
|
||||||
audio_file = ydl.prepare_filename(info_dict)
|
|
||||||
ydl.process_info(info_dict)
|
|
||||||
rep = f"**🎧 Uploader @{bn}**"
|
|
||||||
secmul, dur, dur_arr = 1, 0, duration.split(":")
|
|
||||||
for i in range(len(dur_arr) - 1, -1, -1):
|
|
||||||
dur += int(float(dur_arr[i])) * secmul
|
|
||||||
secmul *= 60
|
|
||||||
m.edit("📤 uploading file...")
|
|
||||||
message.reply_audio(
|
|
||||||
audio_file,
|
|
||||||
caption=rep,
|
|
||||||
thumb=thumb_name,
|
|
||||||
parse_mode="md",
|
|
||||||
title=title,
|
|
||||||
duration=dur,
|
|
||||||
)
|
|
||||||
m.delete()
|
|
||||||
except Exception as e:
|
|
||||||
m.edit("❌ error, wait for bot owner to fix")
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.remove(audio_file)
|
|
||||||
os.remove(thumb_name)
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
|
||||||
command(["vsong", f"vsong@{bn}", "video", f"video@{bn}"]) & ~filters.edited
|
|
||||||
)
|
|
||||||
async def vsong(client, message):
|
|
||||||
ydl_opts = {
|
|
||||||
"format": "best",
|
|
||||||
"keepvideo": True,
|
|
||||||
"prefer_ffmpeg": False,
|
|
||||||
"geo_bypass": True,
|
|
||||||
"outtmpl": "%(title)s.%(ext)s",
|
|
||||||
"quite": True,
|
|
||||||
}
|
|
||||||
query = " ".join(message.command[1:])
|
|
||||||
try:
|
|
||||||
results = YoutubeSearch(query, max_results=1).to_dict()
|
|
||||||
link = f"https://youtube.com{results[0]['url_suffix']}"
|
|
||||||
title = results[0]["title"][:40]
|
|
||||||
thumbnail = results[0]["thumbnails"][0]
|
|
||||||
thumb_name = f"{title}.jpg"
|
|
||||||
thumb = requests.get(thumbnail, allow_redirects=True)
|
|
||||||
open(thumb_name, "wb").write(thumb.content)
|
|
||||||
results[0]["duration"]
|
|
||||||
results[0]["url_suffix"]
|
|
||||||
results[0]["views"]
|
|
||||||
message.from_user.mention
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
try:
|
|
||||||
msg = await message.reply("📥 **downloading video...**")
|
|
||||||
with YoutubeDL(ydl_opts) as ytdl:
|
|
||||||
ytdl_data = ytdl.extract_info(link, download=True)
|
|
||||||
file_name = ytdl.prepare_filename(ytdl_data)
|
|
||||||
except Exception as e:
|
|
||||||
return await msg.edit(f"🚫 **error:** {e}")
|
|
||||||
preview = wget.download(thumbnail)
|
|
||||||
await msg.edit("📤 **uploading video...**")
|
|
||||||
await message.reply_video(
|
|
||||||
file_name,
|
|
||||||
duration=int(ytdl_data["duration"]),
|
|
||||||
thumb=preview,
|
|
||||||
caption=ytdl_data["title"],
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
os.remove(file_name)
|
|
||||||
await msg.delete()
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["lyric", f"lyric@{bn}", "lyrics"]))
|
|
||||||
async def get_lyric_genius(_, message: Message):
|
|
||||||
if len(message.command) < 2:
|
|
||||||
return await message.reply_text("**usage:**\n\n/lyrics (song name)")
|
|
||||||
m = await message.reply_text("🔍 Searching lyrics...")
|
|
||||||
query = message.text.split(None, 1)[1]
|
|
||||||
x = "OXaVabSRKQLqwpiYOn-E4Y7k3wj-TNdL5RfDPXlnXhCErbcqVvdCF-WnMR5TBctI"
|
|
||||||
y = lyricsgenius.Genius(x)
|
|
||||||
y.verbose = False
|
|
||||||
S = y.search_song(query, get_full_info=False)
|
|
||||||
if S is None:
|
|
||||||
return await m.edit("❌ `404` lyrics not found")
|
|
||||||
xxx = f"""
|
|
||||||
**Song Name:** __{query}__
|
|
||||||
**Artist Name:** {S.artist}
|
|
||||||
**__Lyrics:__**
|
|
||||||
{S.lyrics}"""
|
|
||||||
if len(xxx) > 4096:
|
|
||||||
await m.delete()
|
|
||||||
filename = "lyrics.txt"
|
|
||||||
with open(filename, "w+", encoding="utf8") as out_file:
|
|
||||||
out_file.write(str(xxx.strip()))
|
|
||||||
await message.reply_document(
|
|
||||||
document=filename,
|
|
||||||
caption=f"**OUTPUT:**\n\n`Lyrics Text`",
|
|
||||||
quote=False,
|
|
||||||
)
|
|
||||||
os.remove(filename)
|
|
||||||
else:
|
|
||||||
await m.edit(xxx)
|
|
@ -1,48 +0,0 @@
|
|||||||
from pyrogram import Client, errors
|
|
||||||
from pyrogram.types import (
|
|
||||||
InlineQuery,
|
|
||||||
InlineQueryResultArticle,
|
|
||||||
InputTextMessageContent,
|
|
||||||
)
|
|
||||||
from youtubesearchpython import VideosSearch
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_inline_query()
|
|
||||||
async def inline(client: Client, query: InlineQuery):
|
|
||||||
answers = []
|
|
||||||
search_query = query.query.lower().strip().rstrip()
|
|
||||||
|
|
||||||
if search_query == "":
|
|
||||||
await client.answer_inline_query(
|
|
||||||
query.id,
|
|
||||||
results=answers,
|
|
||||||
switch_pm_text="type a youtube video name...",
|
|
||||||
switch_pm_parameter="help",
|
|
||||||
cache_time=0,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
search = VideosSearch(search_query, limit=50)
|
|
||||||
|
|
||||||
for result in search.result()["result"]:
|
|
||||||
answers.append(
|
|
||||||
InlineQueryResultArticle(
|
|
||||||
title=result["title"],
|
|
||||||
description="{}, {} views.".format(
|
|
||||||
result["duration"], result["viewCount"]["short"]
|
|
||||||
),
|
|
||||||
input_message_content=InputTextMessageContent(
|
|
||||||
"🔗 https://www.youtube.com/watch?v={}".format(result["id"])
|
|
||||||
),
|
|
||||||
thumb_url=result["thumbnails"][0]["url"],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
await query.answer(results=answers, cache_time=0)
|
|
||||||
except errors.QueryIdInvalid:
|
|
||||||
await query.answer(
|
|
||||||
results=answers,
|
|
||||||
cache_time=0,
|
|
||||||
switch_pm_text="error: search timed out",
|
|
||||||
switch_pm_parameter="",
|
|
||||||
)
|
|
285
program/music.py
285
program/music.py
@ -1,285 +0,0 @@
|
|||||||
# Copyright (C) 2021 By Veez Music-Project
|
|
||||||
# Commit Start Date 20/10/2021
|
|
||||||
# Finished On 28/10/2021
|
|
||||||
|
|
||||||
|
|
||||||
# pyrogram stuff
|
|
||||||
from pyrogram import Client
|
|
||||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
|
||||||
from pyrogram.types import InlineKeyboardMarkup, Message
|
|
||||||
# pytgcalls stuff
|
|
||||||
from pytgcalls import StreamType
|
|
||||||
from pytgcalls.types.input_stream import AudioPiped
|
|
||||||
from pytgcalls.types.input_stream.quality import HighQualityAudio
|
|
||||||
# repository stuff
|
|
||||||
from program.utils.inline import stream_markup
|
|
||||||
from driver.design.thumbnail import thumb
|
|
||||||
from driver.design.chatname import CHAT_TITLE
|
|
||||||
from driver.filters import command, other_filters
|
|
||||||
from driver.queues import QUEUE, add_to_queue
|
|
||||||
from driver.veez import call_py, user
|
|
||||||
from driver.utils import bash
|
|
||||||
from config import BOT_USERNAME, IMG_1, IMG_2
|
|
||||||
# youtube-dl stuff
|
|
||||||
from youtubesearchpython import VideosSearch
|
|
||||||
|
|
||||||
|
|
||||||
def ytsearch(query: str):
|
|
||||||
try:
|
|
||||||
search = VideosSearch(query, limit=1).result()
|
|
||||||
data = search["result"][0]
|
|
||||||
songname = data["title"]
|
|
||||||
url = data["link"]
|
|
||||||
duration = data["duration"]
|
|
||||||
thumbnail = f"https://i.ytimg.com/vi/{data['id']}/hqdefault.jpg"
|
|
||||||
return [songname, url, duration, thumbnail]
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
async def ytdl(link: str):
|
|
||||||
stdout, stderr = await bash(
|
|
||||||
f'youtube-dl -g -f "best[height<=?720][width<=?1280]" {link}'
|
|
||||||
)
|
|
||||||
if stdout:
|
|
||||||
return 1, stdout
|
|
||||||
return 0, stderr
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters)
|
|
||||||
async def play(c: Client, m: Message):
|
|
||||||
await m.delete()
|
|
||||||
replied = m.reply_to_message
|
|
||||||
chat_id = m.chat.id
|
|
||||||
user_id = m.from_user.id
|
|
||||||
if m.sender_chat:
|
|
||||||
return await m.reply_text(
|
|
||||||
"you're an __Anonymous__ Admin !\n\n» revert back to user account from admin rights."
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
aing = await c.get_me()
|
|
||||||
except Exception as e:
|
|
||||||
return await m.reply_text(f"error:\n\n{e}")
|
|
||||||
a = await c.get_chat_member(chat_id, aing.id)
|
|
||||||
if a.status != "administrator":
|
|
||||||
await m.reply_text(
|
|
||||||
f"💡 To use me, I need to be an **Administrator** with the following **permissions**:\n\n» ❌ __Delete messages__\n» ❌ __Invite users__\n» ❌ __Manage video chat__\n\nOnce done, type /reload"
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
await m.reply_text(
|
|
||||||
"💡 To use me, Give me the following permission below:"
|
|
||||||
+ "\n\n» ❌ __Manage video chat__\n\nOnce done, try again."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if not a.can_delete_messages:
|
|
||||||
await m.reply_text(
|
|
||||||
"💡 To use me, Give me the following permission below:"
|
|
||||||
+ "\n\n» ❌ __Delete messages__\n\nOnce done, try again."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if not a.can_invite_users:
|
|
||||||
await m.reply_text(
|
|
||||||
"💡 To use me, Give me the following permission below:"
|
|
||||||
+ "\n\n» ❌ __Add users__\n\nOnce done, try again."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
ubot = (await user.get_me()).id
|
|
||||||
b = await c.get_chat_member(chat_id, ubot)
|
|
||||||
if b.status == "kicked":
|
|
||||||
await c.unban_chat_member(chat_id, ubot)
|
|
||||||
invitelink = await c.export_chat_invite_link(chat_id)
|
|
||||||
if invitelink.startswith("https://t.me/+"):
|
|
||||||
invitelink = invitelink.replace(
|
|
||||||
"https://t.me/+", "https://t.me/joinchat/"
|
|
||||||
)
|
|
||||||
await user.join_chat(invitelink)
|
|
||||||
except UserNotParticipant:
|
|
||||||
try:
|
|
||||||
invitelink = await c.export_chat_invite_link(chat_id)
|
|
||||||
if invitelink.startswith("https://t.me/+"):
|
|
||||||
invitelink = invitelink.replace(
|
|
||||||
"https://t.me/+", "https://t.me/joinchat/"
|
|
||||||
)
|
|
||||||
await user.join_chat(invitelink)
|
|
||||||
except UserAlreadyParticipant:
|
|
||||||
pass
|
|
||||||
except Exception as e:
|
|
||||||
return await m.reply_text(
|
|
||||||
f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
|
|
||||||
)
|
|
||||||
if replied:
|
|
||||||
if replied.audio or replied.voice:
|
|
||||||
suhu = await replied.reply("📥 **downloading audio...**")
|
|
||||||
dl = await replied.download()
|
|
||||||
link = replied.link
|
|
||||||
|
|
||||||
try:
|
|
||||||
if replied.audio:
|
|
||||||
songname = replied.audio.title[:70]
|
|
||||||
songname = replied.audio.file_name[:70]
|
|
||||||
duration = replied.audio.duration
|
|
||||||
elif replied.voice:
|
|
||||||
songname = "Voice Note"
|
|
||||||
duration = replied.voice.duration
|
|
||||||
except BaseException:
|
|
||||||
songname = "Audio"
|
|
||||||
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0)
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await suhu.delete()
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=f"{IMG_1}",
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
await suhu.edit("🔄 **Joining vc...**")
|
|
||||||
await call_py.join_group_call(
|
|
||||||
chat_id,
|
|
||||||
AudioPiped(
|
|
||||||
dl,
|
|
||||||
),
|
|
||||||
stream_type=StreamType().local_stream,
|
|
||||||
)
|
|
||||||
add_to_queue(chat_id, songname, dl, link, "Audio", 0)
|
|
||||||
await suhu.delete()
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
requester = (
|
|
||||||
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=f"{IMG_2}",
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await suhu.delete()
|
|
||||||
await m.reply_text(f"🚫 error:\n\n» {e}")
|
|
||||||
else:
|
|
||||||
if len(m.command) < 2:
|
|
||||||
await m.reply(
|
|
||||||
"» reply to an **audio file** or **give something to search.**"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
suhu = await c.send_message(chat_id, "🔍 **Searching...**")
|
|
||||||
query = m.text.split(None, 1)[1]
|
|
||||||
search = ytsearch(query)
|
|
||||||
if search == 0:
|
|
||||||
await suhu.edit("❌ **no results found.**")
|
|
||||||
else:
|
|
||||||
songname = search[0]
|
|
||||||
title = search[0]
|
|
||||||
url = search[1]
|
|
||||||
duration = search[2]
|
|
||||||
thumbnail = search[3]
|
|
||||||
userid = m.from_user.id
|
|
||||||
gcname = m.chat.title
|
|
||||||
ctitle = await CHAT_TITLE(gcname)
|
|
||||||
image = await thumb(thumbnail, title, userid, ctitle)
|
|
||||||
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()
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
await suhu.edit("🔄 **Joining vc...**")
|
|
||||||
await call_py.join_group_call(
|
|
||||||
chat_id,
|
|
||||||
AudioPiped(
|
|
||||||
ytlink,
|
|
||||||
HighQualityAudio(),
|
|
||||||
),
|
|
||||||
stream_type=StreamType().local_stream,
|
|
||||||
)
|
|
||||||
add_to_queue(chat_id, songname, ytlink, url, "Audio", 0)
|
|
||||||
await suhu.delete()
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
requester = (
|
|
||||||
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
except Exception as ep:
|
|
||||||
await suhu.delete()
|
|
||||||
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 c.send_message(chat_id, "🔍 **Searching...**")
|
|
||||||
query = m.text.split(None, 1)[1]
|
|
||||||
search = ytsearch(query)
|
|
||||||
if search == 0:
|
|
||||||
await suhu.edit("❌ **no results found.**")
|
|
||||||
else:
|
|
||||||
songname = search[0]
|
|
||||||
title = search[0]
|
|
||||||
url = search[1]
|
|
||||||
duration = search[2]
|
|
||||||
thumbnail = search[3]
|
|
||||||
userid = m.from_user.id
|
|
||||||
gcname = m.chat.title
|
|
||||||
ctitle = await CHAT_TITLE(gcname)
|
|
||||||
image = await thumb(thumbnail, title, userid, ctitle)
|
|
||||||
format = "bestaudio[ext=m4a]"
|
|
||||||
veez, ytlink = await ytdl(format, 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()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
await suhu.edit("🔄 **Joining vc...**")
|
|
||||||
await call_py.join_group_call(
|
|
||||||
chat_id,
|
|
||||||
AudioPiped(
|
|
||||||
ytlink,
|
|
||||||
HighQualityAudio(),
|
|
||||||
),
|
|
||||||
stream_type=StreamType().local_stream,
|
|
||||||
)
|
|
||||||
add_to_queue(chat_id, songname, ytlink, url, "Audio", 0)
|
|
||||||
await suhu.delete()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
except Exception as ep:
|
|
||||||
await suhu.delete()
|
|
||||||
await m.reply_text(f"🚫 error: `{ep}`")
|
|
@ -1,39 +0,0 @@
|
|||||||
# Copyright (C) 2021 By Veez Music-Project
|
|
||||||
# Commit Start Date 20/10/2021
|
|
||||||
# Finished On 28/10/2021
|
|
||||||
|
|
||||||
from config import BOT_USERNAME
|
|
||||||
from pyrogram.types import (
|
|
||||||
CallbackQuery,
|
|
||||||
InlineKeyboardButton,
|
|
||||||
InlineKeyboardMarkup,
|
|
||||||
Message,
|
|
||||||
)
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from driver.queues import QUEUE, get_queue
|
|
||||||
from driver.filters import command, other_filters
|
|
||||||
|
|
||||||
|
|
||||||
keyboard = InlineKeyboardMarkup(
|
|
||||||
[[InlineKeyboardButton("🗑 Close", callback_data="cls")]]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["playlist", f"playlist@{BOT_USERNAME}", "queue", f"queue@{BOT_USERNAME}"]) & other_filters)
|
|
||||||
async def playlist(client, m: Message):
|
|
||||||
chat_id = m.chat.id
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
chat_queue = get_queue(chat_id)
|
|
||||||
if len(chat_queue)==1:
|
|
||||||
await m.reply(f"💡 **Currently Streaming:**\n\n• [{chat_queue[0][0]}]({chat_queue[0][2]}) | `{chat_queue[0][3]}`", reply_markup=keyboard, disable_web_page_preview=True)
|
|
||||||
else:
|
|
||||||
QUE = f"💡 **Currently Streaming:**\n\n• [{chat_queue[0][0]}]({chat_queue[0][2]}) | `{chat_queue[0][3]}` \n\n**📖 Queue List:**\n"
|
|
||||||
l = len(chat_queue)
|
|
||||||
for x in range (1, l):
|
|
||||||
han = chat_queue[x][0]
|
|
||||||
hok = chat_queue[x][2]
|
|
||||||
hap = chat_queue[x][3]
|
|
||||||
QUE = QUE + "\n" + f"**#{x}** - [{han}]({hok}) | `{hap}`"
|
|
||||||
await m.reply(QUE, reply_markup=keyboard, disable_web_page_preview=True)
|
|
||||||
else:
|
|
||||||
await m.reply("❌ **nothing is currently streaming.**")
|
|
@ -1,50 +0,0 @@
|
|||||||
# Copyright (C) 2021 By VeezMusicProject
|
|
||||||
|
|
||||||
import os
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from pyrogram.types import Message
|
|
||||||
from driver.filters import command, other_filters
|
|
||||||
from driver.decorators import sudo_users_only, errors
|
|
||||||
|
|
||||||
downloads = os.path.realpath("program/downloads")
|
|
||||||
raw = os.path.realpath(".")
|
|
||||||
|
|
||||||
@Client.on_message(command(["rmd", "clear"]) & ~filters.edited)
|
|
||||||
@errors
|
|
||||||
@sudo_users_only
|
|
||||||
async def clear_downloads(_, message: Message):
|
|
||||||
ls_dir = os.listdir(downloads)
|
|
||||||
if ls_dir:
|
|
||||||
for file in os.listdir(downloads):
|
|
||||||
os.remove(os.path.join(downloads, file))
|
|
||||||
await message.reply_text("✅ **deleted all downloaded files**")
|
|
||||||
else:
|
|
||||||
await message.reply_text("❌ **no files downloaded**")
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["rmw", "clean"]) & ~filters.edited)
|
|
||||||
@errors
|
|
||||||
@sudo_users_only
|
|
||||||
async def clear_raw(_, message: Message):
|
|
||||||
ls_dir = os.listdir(raw)
|
|
||||||
if ls_dir:
|
|
||||||
for file in os.listdir(raw):
|
|
||||||
if file.endswith('.raw'):
|
|
||||||
os.remove(os.path.join(raw, file))
|
|
||||||
await message.reply_text("✅ **deleted all raw files**")
|
|
||||||
else:
|
|
||||||
await message.reply_text("❌ **no raw files found**")
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["cleanup"]) & ~filters.edited)
|
|
||||||
@errors
|
|
||||||
@sudo_users_only
|
|
||||||
async def cleanup(_, message: Message):
|
|
||||||
pth = os.path.realpath(".")
|
|
||||||
ls_dir = os.listdir(pth)
|
|
||||||
if ls_dir:
|
|
||||||
for dta in os.listdir(pth):
|
|
||||||
os.system("rm -rf *.raw *.jpg")
|
|
||||||
await message.reply_text("✅ **cleaned**")
|
|
||||||
else:
|
|
||||||
await message.reply_text("✅ **already cleaned**")
|
|
@ -1,50 +0,0 @@
|
|||||||
# credit to TeamYukki for this speedtest module
|
|
||||||
|
|
||||||
import os
|
|
||||||
import wget
|
|
||||||
import speedtest
|
|
||||||
|
|
||||||
from program.utils.formatters import bytes
|
|
||||||
from driver.filters import command, other_filters
|
|
||||||
from driver.decorators import sudo_users_only
|
|
||||||
from config import BOT_USERNAME as bname
|
|
||||||
from driver.veez import bot as app
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from pyrogram.types import Message
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["speedtest", f"speedtest@{bname}"]) & ~filters.edited)
|
|
||||||
async def statsguwid(_, message: Message):
|
|
||||||
m = await message.reply_text("Running server speedtest.")
|
|
||||||
try:
|
|
||||||
test = speedtest.Speedtest()
|
|
||||||
test.get_best_server()
|
|
||||||
m = await m.edit("Running download speedtest..")
|
|
||||||
test.download()
|
|
||||||
m = await m.edit("Running upload speedtest...")
|
|
||||||
test.upload()
|
|
||||||
test.results.share()
|
|
||||||
result = test.results.dict()
|
|
||||||
except Exception as e:
|
|
||||||
return await m.edit(e)
|
|
||||||
m = await m.edit("Sharing speedtest results....")
|
|
||||||
path = wget.download(result["share"])
|
|
||||||
|
|
||||||
output = f"""💡 **SpeedTest Results**
|
|
||||||
|
|
||||||
<u>**Client:**</u>
|
|
||||||
**ISP:** {result['client']['isp']}
|
|
||||||
**Country:** {result['client']['country']}
|
|
||||||
|
|
||||||
<u>**Server:**</u>
|
|
||||||
**Name:** {result['server']['name']}
|
|
||||||
**Country:** {result['server']['country']}, {result['server']['cc']}
|
|
||||||
**Sponsor:** {result['server']['sponsor']}
|
|
||||||
**Latency:** {result['server']['latency']}
|
|
||||||
|
|
||||||
⚡️ **Ping:** {result['ping']}"""
|
|
||||||
msg = await app.send_photo(
|
|
||||||
chat_id=message.chat.id, photo=path, caption=output
|
|
||||||
)
|
|
||||||
os.remove(path)
|
|
||||||
await m.delete()
|
|
166
program/start.py
166
program/start.py
@ -1,166 +0,0 @@
|
|||||||
from datetime import datetime
|
|
||||||
from sys import version_info
|
|
||||||
from time import time
|
|
||||||
|
|
||||||
from config import (
|
|
||||||
ALIVE_IMG,
|
|
||||||
ALIVE_NAME,
|
|
||||||
BOT_NAME,
|
|
||||||
BOT_USERNAME,
|
|
||||||
GROUP_SUPPORT,
|
|
||||||
OWNER_NAME,
|
|
||||||
UPDATES_CHANNEL,
|
|
||||||
)
|
|
||||||
from program import __version__
|
|
||||||
from driver.veez import user
|
|
||||||
from driver.filters import command, other_filters
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from pyrogram import __version__ as pyrover
|
|
||||||
from pytgcalls import (__version__ as pytover)
|
|
||||||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
|
|
||||||
|
|
||||||
__major__ = 0
|
|
||||||
__minor__ = 2
|
|
||||||
__micro__ = 1
|
|
||||||
|
|
||||||
__python_version__ = f"{version_info[0]}.{version_info[1]}.{version_info[2]}"
|
|
||||||
|
|
||||||
|
|
||||||
START_TIME = datetime.utcnow()
|
|
||||||
START_TIME_ISO = START_TIME.replace(microsecond=0).isoformat()
|
|
||||||
TIME_DURATION_UNITS = (
|
|
||||||
("week", 60 * 60 * 24 * 7),
|
|
||||||
("day", 60 * 60 * 24),
|
|
||||||
("hour", 60 * 60),
|
|
||||||
("min", 60),
|
|
||||||
("sec", 1),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def _human_time_duration(seconds):
|
|
||||||
if seconds == 0:
|
|
||||||
return "inf"
|
|
||||||
parts = []
|
|
||||||
for unit, div in TIME_DURATION_UNITS:
|
|
||||||
amount, seconds = divmod(int(seconds), div)
|
|
||||||
if amount > 0:
|
|
||||||
parts.append("{} {}{}".format(amount, unit, "" if amount == 1 else "s"))
|
|
||||||
return ", ".join(parts)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
|
||||||
command(["start", f"start@{BOT_USERNAME}"]) & filters.private & ~filters.edited
|
|
||||||
)
|
|
||||||
async def start_(client: Client, message: Message):
|
|
||||||
await message.reply_text(
|
|
||||||
f"""✨ **Welcome {message.from_user.mention()} !**\n
|
|
||||||
💭 [{BOT_NAME}](https://t.me/{BOT_USERNAME}) **Allows you to play music and video on groups through the new Telegram's video chats!**
|
|
||||||
|
|
||||||
💡 **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!**
|
|
||||||
""",
|
|
||||||
reply_markup=InlineKeyboardMarkup(
|
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"➕ Add me to your Group ➕",
|
|
||||||
url=f"https://t.me/{BOT_USERNAME}?startgroup=true",
|
|
||||||
)
|
|
||||||
],
|
|
||||||
[InlineKeyboardButton("❓ Basic Guide", callback_data="cbhowtouse")],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton("📚 Commands", callback_data="cbcmds"),
|
|
||||||
InlineKeyboardButton("❤️ Donate", url=f"https://t.me/{OWNER_NAME}"),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"👥 Official Group", url=f"https://t.me/{GROUP_SUPPORT}"
|
|
||||||
),
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"📣 Official Channel", url=f"https://t.me/{UPDATES_CHANNEL}"
|
|
||||||
),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"🌐 Source Code", url="https://github.com/levina-lab/video-stream"
|
|
||||||
)
|
|
||||||
],
|
|
||||||
]
|
|
||||||
),
|
|
||||||
disable_web_page_preview=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
|
||||||
command(["alive", f"alive@{BOT_USERNAME}"]) & filters.group & ~filters.edited
|
|
||||||
)
|
|
||||||
async def alive(c: Client, message: Message):
|
|
||||||
chat_id = message.chat.id
|
|
||||||
current_time = datetime.utcnow()
|
|
||||||
uptime_sec = (current_time - START_TIME).total_seconds()
|
|
||||||
uptime = await _human_time_duration(int(uptime_sec))
|
|
||||||
|
|
||||||
keyboard = InlineKeyboardMarkup(
|
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton("✨ Group", url=f"https://t.me/{GROUP_SUPPORT}"),
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"📣 Channel", url=f"https://t.me/{UPDATES_CHANNEL}"
|
|
||||||
),
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
alive = f"**Hello {message.from_user.mention()}, i'm {BOT_NAME}**\n\n🧑🏼💻 My Master: [{ALIVE_NAME}](https://t.me/{OWNER_NAME})\n👾 Bot Version: `v{__version__}`\n🔥 Pyrogram Version: `{pyrover}`\n🐍 Python Version: `{__python_version__}`\n✨ PyTgCalls Version: `{pytover.__version__}`\n🆙 Uptime Status: `{uptime}`\n\n❤ **Thanks for Adding me here, for playing video & music on your Group's video chat**"
|
|
||||||
|
|
||||||
await c.send_photo(
|
|
||||||
chat_id,
|
|
||||||
photo=f"{ALIVE_IMG}",
|
|
||||||
caption=alive,
|
|
||||||
reply_markup=keyboard,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["ping", f"ping@{BOT_USERNAME}"]) & ~filters.edited)
|
|
||||||
async def ping_pong(client: Client, message: Message):
|
|
||||||
start = time()
|
|
||||||
m_reply = await message.reply_text("pinging...")
|
|
||||||
delta_ping = time() - start
|
|
||||||
await m_reply.edit_text("🏓 `PONG!!`\n" f"⚡️ `{delta_ping * 1000:.3f} ms`")
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["uptime", f"uptime@{BOT_USERNAME}"]) & ~filters.edited)
|
|
||||||
async def get_uptime(client: Client, message: Message):
|
|
||||||
current_time = datetime.utcnow()
|
|
||||||
uptime_sec = (current_time - START_TIME).total_seconds()
|
|
||||||
uptime = await _human_time_duration(int(uptime_sec))
|
|
||||||
await message.reply_text(
|
|
||||||
"🤖 bot status:\n"
|
|
||||||
f"• **uptime:** `{uptime}`\n"
|
|
||||||
f"• **start time:** `{START_TIME_ISO}`"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.new_chat_members)
|
|
||||||
async def new_chat(c: Client, m: Message):
|
|
||||||
ass_uname = (await user.get_me()).username
|
|
||||||
bot_id = (await c.get_me()).id
|
|
||||||
for member in m.new_chat_members:
|
|
||||||
if member.id == bot_id:
|
|
||||||
return await m.reply(
|
|
||||||
"❤️ Thanks for adding me to the **Group** !\n\n"
|
|
||||||
"Appoint me as administrator in the **Group**, otherwise I will not be able to work properly, and don't forget to type `/userbotjoin` for invite the assistant.\n\n"
|
|
||||||
"Once done, then type `/reload`",
|
|
||||||
reply_markup=InlineKeyboardMarkup(
|
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton("📣 Channel", url=f"https://t.me/{UPDATES_CHANNEL}"),
|
|
||||||
InlineKeyboardButton("💭 Support", url=f"https://t.me/{GROUP_SUPPORT}")
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton("👤 Assistant", url=f"https://t.me/{ass_uname}")
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
@ -1,53 +0,0 @@
|
|||||||
# Copyright (C) 2021 Veez Project
|
|
||||||
|
|
||||||
import re
|
|
||||||
import uuid
|
|
||||||
import socket
|
|
||||||
|
|
||||||
import psutil
|
|
||||||
import platform
|
|
||||||
from config import BOT_USERNAME
|
|
||||||
from driver.filters import command
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from driver.decorators import sudo_users_only, humanbytes
|
|
||||||
|
|
||||||
|
|
||||||
# FETCH SYSINFO
|
|
||||||
|
|
||||||
@Client.on_message(command(["sysinfo", f"sysinfo@{BOT_USERNAME}"]) & ~filters.edited)
|
|
||||||
@sudo_users_only
|
|
||||||
async def give_sysinfo(client, message):
|
|
||||||
splatform = platform.system()
|
|
||||||
platform_release = platform.release()
|
|
||||||
platform_version = platform.version()
|
|
||||||
architecture = platform.machine()
|
|
||||||
hostname = socket.gethostname()
|
|
||||||
ip_address = socket.gethostbyname(socket.gethostname())
|
|
||||||
mac_address = ":".join(re.findall("..", "%012x" % uuid.getnode()))
|
|
||||||
processor = platform.processor()
|
|
||||||
ram = humanbytes(round(psutil.virtual_memory().total))
|
|
||||||
cpu_freq = psutil.cpu_freq().current
|
|
||||||
if cpu_freq >= 1000:
|
|
||||||
cpu_freq = f"{round(cpu_freq / 1000, 2)}GHz"
|
|
||||||
else:
|
|
||||||
cpu_freq = f"{round(cpu_freq, 2)}MHz"
|
|
||||||
du = psutil.disk_usage(client.workdir)
|
|
||||||
psutil.disk_io_counters()
|
|
||||||
disk = f"{humanbytes(du.used)} / {humanbytes(du.total)} " f"({du.percent}%)"
|
|
||||||
cpu_len = len(psutil.Process().cpu_affinity())
|
|
||||||
somsg = f"""🖥 **System Information**
|
|
||||||
|
|
||||||
**PlatForm :** `{splatform}`
|
|
||||||
**PlatForm - Release :** `{platform_release}`
|
|
||||||
**PlatForm - Version :** `{platform_version}`
|
|
||||||
**Architecture :** `{architecture}`
|
|
||||||
**HostName :** `{hostname}`
|
|
||||||
**IP :** `{ip_address}`
|
|
||||||
**Mac :** `{mac_address}`
|
|
||||||
**Processor :** `{processor}`
|
|
||||||
**Ram : ** `{ram}`
|
|
||||||
**CPU :** `{cpu_len}`
|
|
||||||
**CPU FREQ :** `{cpu_freq}`
|
|
||||||
**DISK :** `{disk}`
|
|
||||||
"""
|
|
||||||
await message.reply(somsg)
|
|
@ -1,78 +0,0 @@
|
|||||||
import os
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
import asyncio
|
|
||||||
import subprocess
|
|
||||||
from asyncio import sleep
|
|
||||||
|
|
||||||
from git import Repo
|
|
||||||
from pyrogram.types import Message
|
|
||||||
from driver.filters import command
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from os import system, execle, environ
|
|
||||||
from driver.decorators import sudo_users_only
|
|
||||||
from git.exc import InvalidGitRepositoryError
|
|
||||||
from config import UPSTREAM_REPO, BOT_USERNAME
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def gen_chlog(repo, diff):
|
|
||||||
upstream_repo_url = Repo().remotes[0].config_reader.get("url").replace(".git", "")
|
|
||||||
ac_br = repo.active_branch.name
|
|
||||||
ch_log = tldr_log = ""
|
|
||||||
ch = f"<b>updates for <a href={upstream_repo_url}/tree/{ac_br}>[{ac_br}]</a>:</b>"
|
|
||||||
ch_tl = f"updates for {ac_br}:"
|
|
||||||
d_form = "%d/%m/%y || %H:%M"
|
|
||||||
for c in repo.iter_commits(diff):
|
|
||||||
ch_log += (
|
|
||||||
f"\n\n💬 <b>{c.count()}</b> 🗓 <b>[{c.committed_datetime.strftime(d_form)}]</b>\n<b>"
|
|
||||||
f"<a href={upstream_repo_url.rstrip('/')}/commit/{c}>[{c.summary}]</a></b> 👨💻 <code>{c.author}</code>"
|
|
||||||
)
|
|
||||||
tldr_log += f"\n\n💬 {c.count()} 🗓 [{c.committed_datetime.strftime(d_form)}]\n[{c.summary}] 👨💻 {c.author}"
|
|
||||||
if ch_log:
|
|
||||||
return str(ch + ch_log), str(ch_tl + tldr_log)
|
|
||||||
return ch_log, tldr_log
|
|
||||||
|
|
||||||
|
|
||||||
def updater():
|
|
||||||
try:
|
|
||||||
repo = Repo()
|
|
||||||
except InvalidGitRepositoryError:
|
|
||||||
repo = Repo.init()
|
|
||||||
origin = repo.create_remote("upstream", UPSTREAM_REPO)
|
|
||||||
origin.fetch()
|
|
||||||
repo.create_head("main", origin.refs.main)
|
|
||||||
repo.heads.main.set_tracking_branch(origin.refs.main)
|
|
||||||
repo.heads.main.checkout(True)
|
|
||||||
ac_br = repo.active_branch.name
|
|
||||||
if "upstream" in repo.remotes:
|
|
||||||
ups_rem = repo.remote("upstream")
|
|
||||||
else:
|
|
||||||
ups_rem = repo.create_remote("upstream", UPSTREAM_REPO)
|
|
||||||
ups_rem.fetch(ac_br)
|
|
||||||
changelog, tl_chnglog = gen_chlog(repo, f"HEAD..upstream/{ac_br}")
|
|
||||||
return bool(changelog)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["update", f"update@{BOT_USERNAME}"]) & ~filters.edited)
|
|
||||||
@sudo_users_only
|
|
||||||
async def update_repo(_, message: Message):
|
|
||||||
chat_id = message.chat.id
|
|
||||||
msg = await message.reply("🔄 `processing update...`")
|
|
||||||
update_avail = updater()
|
|
||||||
if update_avail:
|
|
||||||
await msg.edit("✅ update finished\n\n• bot restarted, back active again in 1 minutes.")
|
|
||||||
system("git pull -f && pip3 install --no-cache-dir -r requirements.txt")
|
|
||||||
execle(sys.executable, sys.executable, "main.py", environ)
|
|
||||||
return
|
|
||||||
await msg.edit(f"bot is **up-to-date** with [main]({UPSTREAM_REPO}/tree/main)", disable_web_page_preview=True)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["restart", f"restart@{BOT_USERNAME}"]) & ~filters.edited)
|
|
||||||
@sudo_users_only
|
|
||||||
async def restart_bot(_, message: Message):
|
|
||||||
msg = await message.reply("`restarting bot...`")
|
|
||||||
args = [sys.executable, "main.py"]
|
|
||||||
await msg.edit("✅ bot restarted\n\n• now you can use this bot again.")
|
|
||||||
execle(sys.executable, *args, environ)
|
|
||||||
return
|
|
@ -1,86 +0,0 @@
|
|||||||
import asyncio
|
|
||||||
from driver.veez import user
|
|
||||||
from pyrogram.types import Message
|
|
||||||
from pyrogram import Client, filters
|
|
||||||
from config import BOT_USERNAME, SUDO_USERS
|
|
||||||
from driver.filters import command, other_filters
|
|
||||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
|
||||||
from driver.decorators import authorized_users_only, sudo_users_only
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
|
||||||
command(["userbotjoin", f"userbotjoin@{BOT_USERNAME}"]) & other_filters
|
|
||||||
)
|
|
||||||
@authorized_users_only
|
|
||||||
async def join_chat(c: Client, m: Message):
|
|
||||||
chat_id = m.chat.id
|
|
||||||
try:
|
|
||||||
invitelink = await c.export_chat_invite_link(chat_id)
|
|
||||||
if invitelink.startswith("https://t.me/+"):
|
|
||||||
invitelink = invitelink.replace(
|
|
||||||
"https://t.me/+", "https://t.me/joinchat/"
|
|
||||||
)
|
|
||||||
await user.join_chat(invitelink)
|
|
||||||
return await user.send_message(chat_id, "✅ userbot joined chat")
|
|
||||||
except UserAlreadyParticipant:
|
|
||||||
return await user.send_message(chat_id, "✅ userbot already in chat")
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
|
||||||
command(["userbotleave", f"userbotleave@{BOT_USERNAME}"]) & other_filters
|
|
||||||
)
|
|
||||||
@authorized_users_only
|
|
||||||
async def leave_chat(_, m: Message):
|
|
||||||
chat_id = m.chat.id
|
|
||||||
try:
|
|
||||||
await user.leave_chat(chat_id)
|
|
||||||
return await _.send_message(
|
|
||||||
chat_id,
|
|
||||||
"✅ userbot leaved chat",
|
|
||||||
)
|
|
||||||
except UserNotParticipant:
|
|
||||||
return await _.send_message(
|
|
||||||
chat_id,
|
|
||||||
"❌ userbot already leave chat",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["leaveall", f"leaveall@{BOT_USERNAME}"]))
|
|
||||||
@sudo_users_only
|
|
||||||
async def leave_all(client, message):
|
|
||||||
if message.from_user.id not in SUDO_USERS:
|
|
||||||
return
|
|
||||||
|
|
||||||
left = 0
|
|
||||||
failed = 0
|
|
||||||
|
|
||||||
msg = await message.reply("🔄 Userbot leaving all Group !")
|
|
||||||
async for dialog in user.iter_dialogs():
|
|
||||||
try:
|
|
||||||
await user.leave_chat(dialog.chat.id)
|
|
||||||
left += 1
|
|
||||||
await msg.edit(
|
|
||||||
f"Userbot leaving all Group...\n\nLeft: {left} chats.\nFailed: {failed} chats."
|
|
||||||
)
|
|
||||||
except BaseException:
|
|
||||||
failed += 1
|
|
||||||
await msg.edit(
|
|
||||||
f"Userbot leaving...\n\nLeft: {left} chats.\nFailed: {failed} chats."
|
|
||||||
)
|
|
||||||
await asyncio.sleep(0.7)
|
|
||||||
await msg.delete()
|
|
||||||
await client.send_message(
|
|
||||||
message.chat.id, f"✅ Left from: {left} chats.\n❌ Failed in: {failed} chats."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.left_chat_member)
|
|
||||||
async def ubot_leave(c: Client, m: Message):
|
|
||||||
# ass_id = (await user.get_me()).id
|
|
||||||
bot_id = (await c.get_me()).id
|
|
||||||
chat_id = m.chat.id
|
|
||||||
left_member = m.left_chat_member
|
|
||||||
if left_member.id == bot_id:
|
|
||||||
await user.leave_chat(chat_id)
|
|
||||||
# elif left_member.id == ass_id:
|
|
||||||
# await c.leave_chat(chat_id)
|
|
@ -1,10 +0,0 @@
|
|||||||
def bytes(size: float) -> str:
|
|
||||||
if not size:
|
|
||||||
return ""
|
|
||||||
power = 1024
|
|
||||||
t_n = 0
|
|
||||||
power_dict = {0: " ", 1: "Ki", 2: "Mi", 3: "Gi", 4: "Ti"}
|
|
||||||
while size > power:
|
|
||||||
size /= power
|
|
||||||
t_n += 1
|
|
||||||
return "{:.2f} {}B".format(size, power_dict[t_n])
|
|
@ -1,58 +0,0 @@
|
|||||||
""" inline section button """
|
|
||||||
|
|
||||||
from pyrogram.types import (
|
|
||||||
CallbackQuery,
|
|
||||||
InlineKeyboardButton,
|
|
||||||
InlineKeyboardMarkup,
|
|
||||||
Message,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def stream_markup(user_id):
|
|
||||||
buttons = [
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(text="• Mᴇɴᴜ", callback_data=f'cbmenu | {user_id}'),
|
|
||||||
InlineKeyboardButton(text="• Cʟᴏsᴇ", callback_data=f'cls'),
|
|
||||||
],
|
|
||||||
]
|
|
||||||
return buttons
|
|
||||||
|
|
||||||
|
|
||||||
def menu_markup(user_id):
|
|
||||||
buttons = [
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(text="⏹", callback_data=f'cbstop | {user_id}'),
|
|
||||||
InlineKeyboardButton(text="⏸", callback_data=f'cbpause | {user_id}'),
|
|
||||||
InlineKeyboardButton(text="▶️", callback_data=f'cbresume | {user_id}'),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(text="🔇", callback_data=f'cbmute | {user_id}'),
|
|
||||||
InlineKeyboardButton(text="🔊", callback_data=f'cbunmute | {user_id}'),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(text="🗑 Close", callback_data='cls'),
|
|
||||||
]
|
|
||||||
]
|
|
||||||
return buttons
|
|
||||||
|
|
||||||
|
|
||||||
close_mark = InlineKeyboardMarkup(
|
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"🗑 Close", callback_data="cls"
|
|
||||||
)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
back_mark = InlineKeyboardMarkup(
|
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"🔙 Go Back", callback_data="cbmenu"
|
|
||||||
)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
452
program/video.py
452
program/video.py
@ -1,452 +0,0 @@
|
|||||||
# Copyright (C) 2021 By Veez Music-Project
|
|
||||||
# Commit Start Date 20/10/2021
|
|
||||||
# Finished On 28/10/2021
|
|
||||||
|
|
||||||
import re
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from config import BOT_USERNAME, IMG_1, IMG_2
|
|
||||||
from program.utils.inline import stream_markup
|
|
||||||
from driver.design.thumbnail import thumb
|
|
||||||
from driver.design.chatname import CHAT_TITLE
|
|
||||||
from driver.filters import command, other_filters
|
|
||||||
from driver.queues import QUEUE, add_to_queue
|
|
||||||
from driver.veez import call_py, user
|
|
||||||
from pyrogram import Client
|
|
||||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
|
||||||
from pyrogram.types import InlineKeyboardMarkup, Message
|
|
||||||
from pytgcalls import StreamType
|
|
||||||
from pytgcalls.types.input_stream import AudioVideoPiped
|
|
||||||
from pytgcalls.types.input_stream.quality import (
|
|
||||||
HighQualityAudio,
|
|
||||||
HighQualityVideo,
|
|
||||||
LowQualityVideo,
|
|
||||||
MediumQualityVideo,
|
|
||||||
)
|
|
||||||
from youtubesearchpython import VideosSearch
|
|
||||||
|
|
||||||
|
|
||||||
def ytsearch(query: str):
|
|
||||||
try:
|
|
||||||
search = VideosSearch(query, limit=1).result()
|
|
||||||
data = search["result"][0]
|
|
||||||
songname = data["title"]
|
|
||||||
url = data["link"]
|
|
||||||
duration = data["duration"]
|
|
||||||
thumbnail = f"https://i.ytimg.com/vi/{data['id']}/hqdefault.jpg"
|
|
||||||
return [songname, url, duration, thumbnail]
|
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["vplay", f"vplay@{BOT_USERNAME}"]) & other_filters)
|
|
||||||
async def vplay(c: Client, m: Message):
|
|
||||||
await m.delete()
|
|
||||||
replied = m.reply_to_message
|
|
||||||
chat_id = m.chat.id
|
|
||||||
user_id = m.from_user.id
|
|
||||||
if m.sender_chat:
|
|
||||||
return await m.reply_text(
|
|
||||||
"you're an __Anonymous__ Admin !\n\n» revert back to user account from admin rights."
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
aing = await c.get_me()
|
|
||||||
except Exception as e:
|
|
||||||
return await m.reply_text(f"error:\n\n{e}")
|
|
||||||
a = await c.get_chat_member(chat_id, aing.id)
|
|
||||||
if a.status != "administrator":
|
|
||||||
await m.reply_text(
|
|
||||||
f"💡 To use me, I need to be an **Administrator** with the following **permissions**:\n\n» ❌ __Delete messages__\n» ❌ __Invite users__\n» ❌ __Manage video chat__\n\nOnce done, type /reload"
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
await m.reply_text(
|
|
||||||
"💡 To use me, Give me the following permission below:"
|
|
||||||
+ "\n\n» ❌ __Manage video chat__\n\nOnce done, try again."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if not a.can_delete_messages:
|
|
||||||
await m.reply_text(
|
|
||||||
"💡 To use me, Give me the following permission below:"
|
|
||||||
+ "\n\n» ❌ __Delete messages__\n\nOnce done, try again."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if not a.can_invite_users:
|
|
||||||
await m.reply_text(
|
|
||||||
"💡 To use me, Give me the following permission below:"
|
|
||||||
+ "\n\n» ❌ __Add users__\n\nOnce done, try again."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
ubot = (await user.get_me()).id
|
|
||||||
b = await c.get_chat_member(chat_id, ubot)
|
|
||||||
if b.status == "kicked":
|
|
||||||
await c.unban_chat_member(chat_id, ubot)
|
|
||||||
invitelink = await c.export_chat_invite_link(chat_id)
|
|
||||||
if invitelink.startswith("https://t.me/+"):
|
|
||||||
invitelink = invitelink.replace(
|
|
||||||
"https://t.me/+", "https://t.me/joinchat/"
|
|
||||||
)
|
|
||||||
await user.join_chat(invitelink)
|
|
||||||
except UserNotParticipant:
|
|
||||||
try:
|
|
||||||
invitelink = await c.export_chat_invite_link(chat_id)
|
|
||||||
if invitelink.startswith("https://t.me/+"):
|
|
||||||
invitelink = invitelink.replace(
|
|
||||||
"https://t.me/+", "https://t.me/joinchat/"
|
|
||||||
)
|
|
||||||
await user.join_chat(invitelink)
|
|
||||||
except UserAlreadyParticipant:
|
|
||||||
pass
|
|
||||||
except Exception as e:
|
|
||||||
return await m.reply_text(
|
|
||||||
f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
|
|
||||||
)
|
|
||||||
|
|
||||||
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)
|
|
||||||
else:
|
|
||||||
Q = 720
|
|
||||||
await loser.edit(
|
|
||||||
"» __only 720, 480, 360 allowed__ \n💡 **now streaming video in 720p**"
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
if replied.video:
|
|
||||||
songname = replied.video.file_name[:70]
|
|
||||||
duration = replied.video.duration
|
|
||||||
elif replied.document:
|
|
||||||
songname = replied.document.file_name[:70]
|
|
||||||
duration = replied.document.duration
|
|
||||||
except BaseException:
|
|
||||||
songname = "Video"
|
|
||||||
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
pos = add_to_queue(chat_id, songname, dl, link, "Video", Q)
|
|
||||||
await loser.delete()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=f"{IMG_1}",
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
if Q == 720:
|
|
||||||
amaze = HighQualityVideo()
|
|
||||||
elif Q == 480:
|
|
||||||
amaze = MediumQualityVideo()
|
|
||||||
elif Q == 360:
|
|
||||||
amaze = LowQualityVideo()
|
|
||||||
await loser.edit("🔄 **Joining vc...**")
|
|
||||||
await call_py.join_group_call(
|
|
||||||
chat_id,
|
|
||||||
AudioVideoPiped(
|
|
||||||
dl,
|
|
||||||
HighQualityAudio(),
|
|
||||||
amaze,
|
|
||||||
),
|
|
||||||
stream_type=StreamType().local_stream,
|
|
||||||
)
|
|
||||||
add_to_queue(chat_id, songname, dl, link, "Video", Q)
|
|
||||||
await loser.delete()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=f"{IMG_2}",
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
if len(m.command) < 2:
|
|
||||||
await m.reply(
|
|
||||||
"» reply to an **video file** or **give something to search.**"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
loser = await c.send_message(chat_id, "🔍 **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]
|
|
||||||
title = search[0]
|
|
||||||
url = search[1]
|
|
||||||
duration = search[2]
|
|
||||||
thumbnail = search[3]
|
|
||||||
userid = m.from_user.id
|
|
||||||
gcname = m.chat.title
|
|
||||||
ctitle = await CHAT_TITLE(gcname)
|
|
||||||
image = await thumb(thumbnail, title, userid, ctitle)
|
|
||||||
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()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
await loser.edit("🔄 **Joining vc...**")
|
|
||||||
await call_py.join_group_call(
|
|
||||||
chat_id,
|
|
||||||
AudioVideoPiped(
|
|
||||||
ytlink,
|
|
||||||
HighQualityAudio(),
|
|
||||||
amaze,
|
|
||||||
),
|
|
||||||
stream_type=StreamType().local_stream,
|
|
||||||
)
|
|
||||||
add_to_queue(chat_id, songname, ytlink, url, "Video", Q)
|
|
||||||
await loser.delete()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
except Exception as ep:
|
|
||||||
await loser.delete()
|
|
||||||
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 c.send_message(chat_id, "🔍 **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]
|
|
||||||
title = search[0]
|
|
||||||
url = search[1]
|
|
||||||
duration = search[2]
|
|
||||||
thumbnail = search[3]
|
|
||||||
userid = m.from_user.id
|
|
||||||
gcname = m.chat.title
|
|
||||||
ctitle = await CHAT_TITLE(gcname)
|
|
||||||
image = await thumb(thumbnail, title, userid, ctitle)
|
|
||||||
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()
|
|
||||||
requester = (
|
|
||||||
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
)
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
await loser.edit("🔄 **Joining vc...**")
|
|
||||||
await call_py.join_group_call(
|
|
||||||
chat_id,
|
|
||||||
AudioVideoPiped(
|
|
||||||
ytlink,
|
|
||||||
HighQualityAudio(),
|
|
||||||
amaze,
|
|
||||||
),
|
|
||||||
stream_type=StreamType().local_stream,
|
|
||||||
)
|
|
||||||
add_to_queue(chat_id, songname, ytlink, url, "Video", Q)
|
|
||||||
await loser.delete()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"🗂 **Name:** [{songname}]({url}) |`video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
except Exception as ep:
|
|
||||||
await loser.delete()
|
|
||||||
await m.reply_text(f"🚫 error: `{ep}`")
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["vstream", f"vstream@{BOT_USERNAME}"]) & other_filters)
|
|
||||||
async def vstream(c: Client, m: Message):
|
|
||||||
await m.delete()
|
|
||||||
chat_id = m.chat.id
|
|
||||||
user_id = m.from_user.id
|
|
||||||
if m.sender_chat:
|
|
||||||
return await m.reply_text(
|
|
||||||
"you're an __Anonymous__ Admin !\n\n» revert back to user account from admin rights."
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
aing = await c.get_me()
|
|
||||||
except Exception as e:
|
|
||||||
return await m.reply_text(f"error:\n\n{e}")
|
|
||||||
a = await c.get_chat_member(chat_id, aing.id)
|
|
||||||
if a.status != "administrator":
|
|
||||||
await m.reply_text(
|
|
||||||
f"💡 To use me, I need to be an **Administrator** with the following **permissions**:\n\n» ❌ __Delete messages__\n» ❌ __Invite users__\n» ❌ __Manage video chat__\n\nOnce done, type /reload"
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if not a.can_manage_voice_chats:
|
|
||||||
await m.reply_text(
|
|
||||||
"💡 To use me, Give me the following permission below:"
|
|
||||||
+ "\n\n» ❌ __Manage video chat__\n\nOnce done, try again."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if not a.can_delete_messages:
|
|
||||||
await m.reply_text(
|
|
||||||
"💡 To use me, Give me the following permission below:"
|
|
||||||
+ "\n\n» ❌ __Delete messages__\n\nOnce done, try again."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if not a.can_invite_users:
|
|
||||||
await m.reply_text(
|
|
||||||
"💡 To use me, Give me the following permission below:"
|
|
||||||
+ "\n\n» ❌ __Add users__\n\nOnce done, try again."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
ubot = (await user.get_me()).id
|
|
||||||
b = await c.get_chat_member(chat_id, ubot)
|
|
||||||
if b.status == "kicked":
|
|
||||||
await c.unban_chat_member(chat_id, ubot)
|
|
||||||
invitelink = await c.export_chat_invite_link(chat_id)
|
|
||||||
if invitelink.startswith("https://t.me/+"):
|
|
||||||
invitelink = invitelink.replace(
|
|
||||||
"https://t.me/+", "https://t.me/joinchat/"
|
|
||||||
)
|
|
||||||
await user.join_chat(invitelink)
|
|
||||||
except UserNotParticipant:
|
|
||||||
try:
|
|
||||||
invitelink = await c.export_chat_invite_link(chat_id)
|
|
||||||
if invitelink.startswith("https://t.me/+"):
|
|
||||||
invitelink = invitelink.replace(
|
|
||||||
"https://t.me/+", "https://t.me/joinchat/"
|
|
||||||
)
|
|
||||||
await user.join_chat(invitelink)
|
|
||||||
except UserAlreadyParticipant:
|
|
||||||
pass
|
|
||||||
except Exception as e:
|
|
||||||
return await m.reply_text(
|
|
||||||
f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
|
|
||||||
)
|
|
||||||
|
|
||||||
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 c.send_message(chat_id, "🔄 **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 c.send_message(chat_id, "🔄 **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
|
|
||||||
|
|
||||||
if veez == 0:
|
|
||||||
await loser.edit(f"❌ yt-dl issues detected\n\n» `{livelink}`")
|
|
||||||
else:
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
pos = add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q)
|
|
||||||
await loser.delete()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=f"{IMG_1}",
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
if Q == 720:
|
|
||||||
amaze = HighQualityVideo()
|
|
||||||
elif Q == 480:
|
|
||||||
amaze = MediumQualityVideo()
|
|
||||||
elif Q == 360:
|
|
||||||
amaze = LowQualityVideo()
|
|
||||||
try:
|
|
||||||
await loser.edit("🔄 **Joining vc...**")
|
|
||||||
await call_py.join_group_call(
|
|
||||||
chat_id,
|
|
||||||
AudioVideoPiped(
|
|
||||||
livelink,
|
|
||||||
HighQualityAudio(),
|
|
||||||
amaze,
|
|
||||||
),
|
|
||||||
stream_type=StreamType().live_stream,
|
|
||||||
)
|
|
||||||
add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q)
|
|
||||||
await loser.delete()
|
|
||||||
requester = (
|
|
||||||
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
)
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=f"{IMG_2}",
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **[Video Live]({link}) stream started.**\n\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
except Exception as ep:
|
|
||||||
await loser.delete()
|
|
||||||
await m.reply_text(f"🚫 error: `{ep}`")
|
|
@ -1,33 +0,0 @@
|
|||||||
from config import BOT_USERNAME
|
|
||||||
from driver.filters import command
|
|
||||||
from pyrogram import Client
|
|
||||||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
|
|
||||||
from youtube_search import YoutubeSearch
|
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["search", f"search@{BOT_USERNAME}"]))
|
|
||||||
async def ytsearch(_, message: Message):
|
|
||||||
if len(message.command) < 2:
|
|
||||||
return await message.reply_text("/search **needs an argument !**")
|
|
||||||
query = message.text.split(None, 1)[1]
|
|
||||||
m = await message.reply_text("🔎 **Searching...**")
|
|
||||||
results = YoutubeSearch(query, max_results=5).to_dict()
|
|
||||||
if len(results) == 0:
|
|
||||||
return await m.edit_text("❌ **no results found.**")
|
|
||||||
text = ""
|
|
||||||
for i in range(5):
|
|
||||||
try:
|
|
||||||
text += f"🏷 **Name:** __{results[i]['title']}__\n"
|
|
||||||
text += f"⏱ **Duration:** `{results[i]['duration']}`\n"
|
|
||||||
text += f"👀 **Views:** `{results[i]['views']}`\n"
|
|
||||||
text += f"📣 **Channel:** {results[i]['channel']}\n"
|
|
||||||
text += f"🔗: https://www.youtube.com{results[i]['url_suffix']}\n\n"
|
|
||||||
except IndexError:
|
|
||||||
break
|
|
||||||
await m.edit_text(
|
|
||||||
text,
|
|
||||||
disable_web_page_preview=True,
|
|
||||||
reply_markup=InlineKeyboardMarkup(
|
|
||||||
[[InlineKeyboardButton("🗑 Close", callback_data="cls")]]
|
|
||||||
),
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user