diff --git a/driver/utils.py b/driver/utils.py index 8db3b24..e10b824 100644 --- a/driver/utils.py +++ b/driver/utils.py @@ -51,7 +51,7 @@ async def skip_current_song(chat_id): link = chat_queue[1][2] type = chat_queue[1][3] Q = chat_queue[1][4] - if type == "Audio": + if type == "music": await calls.change_stream( chat_id, AudioPiped( @@ -59,7 +59,7 @@ async def skip_current_song(chat_id): HighQualityAudio(), ), ) - elif type == "Video": + elif type == "video": if Q == 720: hm = HighQualityVideo() elif Q == 480: diff --git a/program/callback.py b/program/callback.py index f983e6a..a21adab 100644 --- a/program/callback.py +++ b/program/callback.py @@ -186,6 +186,7 @@ async def admin_set(_, query: CallbackQuery): » /reload - reload bot and refresh the admin data » /userbotjoin - invite the userbot to join group » /userbotleave - order userbot to leave from group +» /startvc - start/restart the group call ⚡️ __Powered by {BOT_NAME} AI__""", reply_markup=InlineKeyboardMarkup( diff --git a/program/music.py b/program/music.py index fb3d717..a012a75 100644 --- a/program/music.py +++ b/program/music.py @@ -79,7 +79,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str suhu = await m.reply("📥 downloading audio...") dl = await replied.download() link = replied.link - songname = "Audio" + songname = "music" thumbnail = f"{IMG_5}" duration = "00:00" 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) duration = convert_seconds(replied.audio.duration) elif replied.voice: - songname = "Voice Note" + songname = "voice note" duration = convert_seconds(replied.voice.duration) except BaseException: pass - # recheck + if not thumbnail: thumbnail = f"{IMG_5}" @@ -110,7 +110,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str title = songname userid = m.from_user.id 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})" buttons = stream_markup(user_id) 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, ) - add_to_queue(chat_id, songname, dl, link, "Audio", 0) + add_to_queue(chat_id, songname, dl, link, "music", 0) await suhu.delete() buttons = stream_markup(user_id) requester = ( @@ -226,7 +226,7 @@ async def play(c: Client, m: Message): query = m.text.split(None, 1)[1] search = ytsearch(query) if search == 0: - await suhu.edit("❌ **no results found.**") + await suhu.edit("❌ **no results found**") else: songname = search[0] title = search[0] @@ -244,7 +244,7 @@ async def play(c: Client, m: Message): if chat_id in QUEUE: await suhu.edit("🔄 Queueing Track...") pos = add_to_queue( - chat_id, songname, ytlink, url, "Audio", 0 + chat_id, songname, ytlink, url, "music", 0 ) await suhu.delete() buttons = stream_markup(user_id) @@ -268,7 +268,7 @@ async def play(c: Client, m: Message): ), 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() buttons = stream_markup(user_id) requester = ( @@ -301,7 +301,7 @@ async def play(c: Client, m: Message): query = m.text.split(None, 1)[1] search = ytsearch(query) if search == 0: - await suhu.edit("❌ **no results found.**") + await suhu.edit("❌ **no results found**") else: songname = search[0] title = search[0] @@ -318,7 +318,7 @@ async def play(c: Client, m: Message): else: if chat_id in QUEUE: 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() requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" buttons = stream_markup(user_id) @@ -341,7 +341,7 @@ async def play(c: Client, m: Message): ), 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() requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" buttons = stream_markup(user_id) diff --git a/program/userbot_tools.py b/program/userbot_tools.py index c38184d..f77c305 100644 --- a/program/userbot_tools.py +++ b/program/userbot_tools.py @@ -10,7 +10,9 @@ from driver.decorators import authorized_users_only, bot_creator, check_blacklis from pyrogram.types import Message 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 async def leave_all(client, message): 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) async def bot_kicked(c: Client, m: Message): bot_id = me_bot.id diff --git a/program/video.py b/program/video.py index 17e49bb..7119d45 100644 --- a/program/video.py +++ b/program/video.py @@ -105,7 +105,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str Q = int(pq) else: await loser.edit( - "» only 720, 480, 360 allowed\n\n💡 now streaming video in **720p**" + "Streaming the local video in 720p quality" ) try: if replied.video: @@ -114,7 +114,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str elif replied.document: songname = replied.document.file_name[:80] except BaseException: - songname = "Video" + songname = "video" if chat_id in QUEUE: 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 thumbnail = f"{IMG_5}" 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() requester = f"[{m.from_user.first_name}](tg://user?id={m.from_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, ) - add_to_queue(chat_id, songname, dl, link, "Video", Q) + 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) @@ -260,7 +260,7 @@ async def vplay(c: Client, m: Message): if chat_id in QUEUE: await loser.edit("🔄 Queueing Track...") pos = add_to_queue( - chat_id, songname, ytlink, url, "Video", Q + chat_id, songname, ytlink, url, "video", Q ) await loser.delete() 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, ) - add_to_queue(chat_id, songname, ytlink, url, "Video", Q) + 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) @@ -335,7 +335,7 @@ async def vplay(c: Client, m: Message): else: if chat_id in QUEUE: 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() requester = ( 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, ) - add_to_queue(chat_id, songname, ytlink, url, "Video", Q) + 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) @@ -425,48 +425,52 @@ async def vstream(c: Client, m: Message): ) 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: if len(m.command) == 2: - link = m.text.split(None, 1)[1] Q = 720 + url = m.text.split(None, 1)[1] + search = ytsearch(url) loser = await c.send_message(chat_id, "🔍 **Loading...**") elif len(m.command) == 3: 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] + search = ytsearch(op) if quality == "720" or "480" or "360": Q = int(quality) else: Q = 720 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...**") 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)\/.+" - match = re.match(regex, link) + match = re.match(regex, url) + if match: - veez, livelink = await ytdl(link) + veez, livelink = await ytdl(url) else: - livelink = link + livelink = url veez = 1 if veez == 0: await loser.edit(f"❌ yt-dl issues detected\n\n» `{livelink}`") else: + songname = search[0] if chat_id in QUEUE: 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() 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}", + caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `live`\n🧸 **Requested by:** {requester}", ) else: if Q == 720: @@ -488,7 +492,7 @@ async def vstream(c: Client, m: Message): ), 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() requester = ( 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( photo=f"{IMG_2}", 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: await loser.delete() await remove_active_chat(chat_id)