merge pull request #159 from levina-lab/alpha

improvements
This commit is contained in:
levina 2022-02-21 13:08:16 +07:00 committed by GitHub
commit 888b573807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 35 deletions

View File

@ -51,7 +51,7 @@ async def skip_current_song(chat_id):
link = chat_queue[1][2] link = chat_queue[1][2]
type = chat_queue[1][3] type = chat_queue[1][3]
Q = chat_queue[1][4] Q = chat_queue[1][4]
if type == "Audio": if type == "music":
await calls.change_stream( await calls.change_stream(
chat_id, chat_id,
AudioPiped( AudioPiped(
@ -59,7 +59,7 @@ async def skip_current_song(chat_id):
HighQualityAudio(), HighQualityAudio(),
), ),
) )
elif type == "Video": elif type == "video":
if Q == 720: if Q == 720:
hm = HighQualityVideo() hm = HighQualityVideo()
elif Q == 480: elif Q == 480:

View File

@ -186,6 +186,7 @@ async def admin_set(_, query: CallbackQuery):
» /reload - reload bot and refresh the admin data » /reload - reload bot and refresh the admin data
» /userbotjoin - invite the userbot to join group » /userbotjoin - invite the userbot to join group
» /userbotleave - order userbot to leave from group » /userbotleave - order userbot to leave from group
» /startvc - start/restart the group call
__Powered by {BOT_NAME} AI__""", __Powered by {BOT_NAME} AI__""",
reply_markup=InlineKeyboardMarkup( reply_markup=InlineKeyboardMarkup(

View File

@ -79,7 +79,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
suhu = await m.reply("📥 downloading audio...") suhu = await m.reply("📥 downloading audio...")
dl = await replied.download() dl = await replied.download()
link = replied.link link = replied.link
songname = "Audio" songname = "music"
thumbnail = f"{IMG_5}" thumbnail = f"{IMG_5}"
duration = "00:00" duration = "00:00"
try: try:
@ -95,11 +95,11 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
thumbnail = await user.download_media(replied.audio.thumbs[0].file_id) thumbnail = await user.download_media(replied.audio.thumbs[0].file_id)
duration = convert_seconds(replied.audio.duration) duration = convert_seconds(replied.audio.duration)
elif replied.voice: elif replied.voice:
songname = "Voice Note" songname = "voice note"
duration = convert_seconds(replied.voice.duration) duration = convert_seconds(replied.voice.duration)
except BaseException: except BaseException:
pass pass
# recheck
if not thumbnail: if not thumbnail:
thumbnail = f"{IMG_5}" thumbnail = f"{IMG_5}"
@ -110,7 +110,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
title = songname title = songname
userid = m.from_user.id userid = m.from_user.id
image = await thumb(thumbnail, title, userid, ctitle) image = await thumb(thumbnail, title, userid, ctitle)
pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0) pos = add_to_queue(chat_id, songname, dl, link, "music", 0)
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
await suhu.delete() await suhu.delete()
@ -141,7 +141,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
), ),
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, "music", 0)
await suhu.delete() await suhu.delete()
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
requester = ( requester = (
@ -226,7 +226,7 @@ async def play(c: Client, m: Message):
query = m.text.split(None, 1)[1] query = m.text.split(None, 1)[1]
search = ytsearch(query) search = ytsearch(query)
if search == 0: if search == 0:
await suhu.edit("❌ **no results found.**") await suhu.edit("❌ **no results found**")
else: else:
songname = search[0] songname = search[0]
title = search[0] title = search[0]
@ -244,7 +244,7 @@ async def play(c: Client, m: Message):
if chat_id in QUEUE: if chat_id in QUEUE:
await suhu.edit("🔄 Queueing Track...") await suhu.edit("🔄 Queueing Track...")
pos = add_to_queue( pos = add_to_queue(
chat_id, songname, ytlink, url, "Audio", 0 chat_id, songname, ytlink, url, "music", 0
) )
await suhu.delete() await suhu.delete()
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
@ -268,7 +268,7 @@ async def play(c: Client, m: Message):
), ),
stream_type=StreamType().local_stream, stream_type=StreamType().local_stream,
) )
add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) add_to_queue(chat_id, songname, ytlink, url, "music", 0)
await suhu.delete() await suhu.delete()
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
requester = ( requester = (
@ -301,7 +301,7 @@ async def play(c: Client, m: Message):
query = m.text.split(None, 1)[1] query = m.text.split(None, 1)[1]
search = ytsearch(query) search = ytsearch(query)
if search == 0: if search == 0:
await suhu.edit("❌ **no results found.**") await suhu.edit("❌ **no results found**")
else: else:
songname = search[0] songname = search[0]
title = search[0] title = search[0]
@ -318,7 +318,7 @@ async def play(c: Client, m: Message):
else: else:
if chat_id in QUEUE: if chat_id in QUEUE:
await suhu.edit("🔄 Queueing Track...") await suhu.edit("🔄 Queueing Track...")
pos = add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) pos = add_to_queue(chat_id, songname, ytlink, url, "music", 0)
await suhu.delete() await suhu.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
@ -341,7 +341,7 @@ async def play(c: Client, m: Message):
), ),
stream_type=StreamType().local_stream, stream_type=StreamType().local_stream,
) )
add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) add_to_queue(chat_id, songname, ytlink, url, "music", 0)
await suhu.delete() await suhu.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
buttons = stream_markup(user_id) buttons = stream_markup(user_id)

View File

@ -10,7 +10,9 @@ from driver.decorators import authorized_users_only, bot_creator, check_blacklis
from pyrogram.types import Message from pyrogram.types import Message
from pyrogram import Client, filters from pyrogram import Client, filters
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant from pyrogram.raw.types import InputPeerChannel
from pyrogram.raw.functions.phone import CreateGroupCall
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant, ChatAdminRequired
@ -58,7 +60,7 @@ async def leave_chat(_, m: Message):
) )
@Client.on_message(command(["leaveall", f"leaveall@{BOT_USERNAME}"])) @Client.on_message(command(["leaveall", f"leaveall@{BOT_USERNAME}"]) & ~filters.edited)
@bot_creator @bot_creator
async def leave_all(client, message): async def leave_all(client, message):
if message.from_user.id not in SUDO_USERS: if message.from_user.id not in SUDO_USERS:
@ -88,6 +90,30 @@ async def leave_all(client, message):
) )
@Client.on_message(command(["startvc", f"startvc@{BOT_USERNAME}"]) & other_filters)
@check_blacklist()
@authorized_users_only
async def start_group_call(c: Client, m: Message):
chat_id = m.chat.id
msg = await c.send_message(chat_id, "`starting...`")
try:
peer = await user.resolve_peer(chat_id)
await user.send(
CreateGroupCall(
peer=InputPeerChannel(
channel_id=peer.channel_id,
access_hash=peer.access_hash,
),
random_id=user.rnd_id() // 9000000000,
)
)
await msg.edit_text("✅ Group call started !")
except ChatAdminRequired:
await msg.edit_text(
"The userbot is not admin in this chat. To start the Group call you must promote the userbot as admin first with permission:\n\n» ❌ manage_video_chats"
)
@Client.on_message(filters.left_chat_member) @Client.on_message(filters.left_chat_member)
async def bot_kicked(c: Client, m: Message): async def bot_kicked(c: Client, m: Message):
bot_id = me_bot.id bot_id = me_bot.id

View File

@ -105,7 +105,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
Q = int(pq) Q = int(pq)
else: else:
await loser.edit( await loser.edit(
"» only 720, 480, 360 allowed\n\n💡 now streaming video in **720p**" "Streaming the local video in 720p quality"
) )
try: try:
if replied.video: if replied.video:
@ -114,7 +114,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
elif replied.document: elif replied.document:
songname = replied.document.file_name[:80] songname = replied.document.file_name[:80]
except BaseException: except BaseException:
songname = "Video" songname = "video"
if chat_id in QUEUE: if chat_id in QUEUE:
await loser.edit("🔄 Queueing Track...") await loser.edit("🔄 Queueing Track...")
@ -124,7 +124,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
userid = m.from_user.id userid = m.from_user.id
thumbnail = f"{IMG_5}" thumbnail = f"{IMG_5}"
image = await thumb(thumbnail, title, userid, ctitle) image = await thumb(thumbnail, title, userid, ctitle)
pos = add_to_queue(chat_id, songname, dl, link, "Video", Q) pos = add_to_queue(chat_id, songname, dl, link, "video", Q)
await loser.delete() await loser.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
@ -162,7 +162,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
), ),
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)
await loser.delete() await loser.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
@ -260,7 +260,7 @@ async def vplay(c: Client, m: Message):
if chat_id in QUEUE: if chat_id in QUEUE:
await loser.edit("🔄 Queueing Track...") await loser.edit("🔄 Queueing Track...")
pos = add_to_queue( pos = add_to_queue(
chat_id, songname, ytlink, url, "Video", Q chat_id, songname, ytlink, url, "video", Q
) )
await loser.delete() await loser.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
@ -285,7 +285,7 @@ async def vplay(c: Client, m: Message):
), ),
stream_type=StreamType().local_stream, stream_type=StreamType().local_stream,
) )
add_to_queue(chat_id, songname, ytlink, url, "Video", Q) add_to_queue(chat_id, songname, ytlink, url, "video", Q)
await loser.delete() await loser.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
@ -335,7 +335,7 @@ async def vplay(c: Client, m: Message):
else: else:
if chat_id in QUEUE: if chat_id in QUEUE:
await loser.edit("🔄 Queueing Track...") await loser.edit("🔄 Queueing Track...")
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()
requester = ( requester = (
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
@ -361,7 +361,7 @@ async def vplay(c: Client, m: Message):
), ),
stream_type=StreamType().local_stream, stream_type=StreamType().local_stream,
) )
add_to_queue(chat_id, songname, ytlink, url, "Video", Q) add_to_queue(chat_id, songname, ytlink, url, "video", Q)
await loser.delete() await loser.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
@ -425,48 +425,52 @@ async def vstream(c: Client, m: Message):
) )
if len(m.command) < 2: if len(m.command) < 2:
await m.reply("» give me a live-link/m3u8 url/youtube link to stream.") await m.reply("» Give me a youtube live url/m3u8 url to stream.")
else: else:
if len(m.command) == 2: if len(m.command) == 2:
link = m.text.split(None, 1)[1]
Q = 720 Q = 720
url = m.text.split(None, 1)[1]
search = ytsearch(url)
loser = await c.send_message(chat_id, "🔍 **Loading...**") loser = await c.send_message(chat_id, "🔍 **Loading...**")
elif len(m.command) == 3: elif len(m.command) == 3:
op = m.text.split(None, 1)[1] op = m.text.split(None, 1)[1]
link = op.split(None, 1)[0] url = op.split(None, 1)[0]
quality = op.split(None, 1)[1] quality = op.split(None, 1)[1]
search = ytsearch(op)
if quality == "720" or "480" or "360": if quality == "720" or "480" or "360":
Q = int(quality) Q = int(quality)
else: else:
Q = 720 Q = 720
await m.reply( await m.reply(
"» only 720, 480, 360 allowed\n\n💡 now streaming video in **720p**" "» Streaming the live video in 720p quality"
) )
loser = await c.send_message(chat_id, "🔍 **Loading...**") loser = await c.send_message(chat_id, "🔍 **Loading...**")
else: else:
await m.reply("`/vstream` {link} {720/480/360}") await m.reply(f"`/vstream` {url} (720/480/360)")
regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+" regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+"
match = re.match(regex, link) match = re.match(regex, url)
if match: if match:
veez, livelink = await ytdl(link) veez, livelink = await ytdl(url)
else: else:
livelink = link livelink = url
veez = 1 veez = 1
if veez == 0: if veez == 0:
await loser.edit(f"❌ yt-dl issues detected\n\n» `{livelink}`") await loser.edit(f"❌ yt-dl issues detected\n\n» `{livelink}`")
else: else:
songname = search[0]
if chat_id in QUEUE: if chat_id in QUEUE:
await loser.edit("🔄 Queueing Track...") await loser.edit("🔄 Queueing Track...")
pos = add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q) pos = add_to_queue(chat_id, songname, livelink, url, "video", Q)
await loser.delete() await loser.delete()
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
await m.reply_photo( await m.reply_photo(
photo=f"{IMG_1}", photo=f"{IMG_1}",
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"💡 **Track added to queue »** `{pos}`\n\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `live`\n🧸 **Requested by:** {requester}",
) )
else: else:
if Q == 720: if Q == 720:
@ -488,7 +492,7 @@ async def vstream(c: Client, m: Message):
), ),
stream_type=StreamType().live_stream, stream_type=StreamType().live_stream,
) )
add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q) add_to_queue(chat_id, songname, livelink, url, "video", Q)
await loser.delete() await loser.delete()
requester = ( requester = (
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
@ -497,8 +501,9 @@ async def vstream(c: Client, m: Message):
await m.reply_photo( await m.reply_photo(
photo=f"{IMG_2}", photo=f"{IMG_2}",
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"💡 **[Video Live]({link}) stream started.**\n\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", caption=f"🗂 **Name:** [{songname}]({url}) | `live`\n🧸 **Requested by:** {requester}",
) )
await idle()
except Exception as ep: except Exception as ep:
await loser.delete() await loser.delete()
await remove_active_chat(chat_id) await remove_active_chat(chat_id)