From e50fb3ede6f3458ecc0958e11b0ec763477fe4b9 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 18 Jan 2022 17:03:15 +0700 Subject: [PATCH] removal --- program/__init__.py | 1 - program/admins.py | 296 ------------------------- program/callback.py | 202 ----------------- program/downloader.py | 152 ------------- program/inline.py | 48 ---- program/music.py | 277 ----------------------- program/playlist.py | 39 ---- program/rmtrash.py | 50 ----- program/start.py | 164 -------------- program/sysinfo.py | 53 ----- program/updater.py | 77 ------- program/userbot_tools.py | 93 -------- program/video.py | 461 --------------------------------------- program/ytsearch.py | 50 ----- 14 files changed, 1963 deletions(-) delete mode 100644 program/__init__.py delete mode 100644 program/admins.py delete mode 100644 program/callback.py delete mode 100644 program/downloader.py delete mode 100644 program/inline.py delete mode 100644 program/music.py delete mode 100644 program/playlist.py delete mode 100644 program/rmtrash.py delete mode 100644 program/start.py delete mode 100644 program/sysinfo.py delete mode 100644 program/updater.py delete mode 100644 program/userbot_tools.py delete mode 100644 program/video.py delete mode 100644 program/ytsearch.py diff --git a/program/__init__.py b/program/__init__.py deleted file mode 100644 index 906d362..0000000 --- a/program/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.6.0" diff --git a/program/admins.py b/program/admins.py deleted file mode 100644 index 0b8b8bd..0000000 --- a/program/admins.py +++ /dev/null @@ -1,296 +0,0 @@ -from cache.admins import admins -from driver.veez import call_py -from pyrogram import Client, filters -from driver.decorators import authorized_users_only -from driver.filters import command, other_filters -from driver.queues import QUEUE, clear_queue -from driver.utils import skip_current_song, skip_item -from config import BOT_USERNAME, GROUP_SUPPORT, IMG_3, UPDATES_CHANNEL -from pyrogram.types import ( - CallbackQuery, - InlineKeyboardButton, - InlineKeyboardMarkup, - Message, -) - - -bttn = InlineKeyboardMarkup( - [[InlineKeyboardButton("🔙 Go Back", callback_data="cbmenu")]] -) - - -bcl = InlineKeyboardMarkup( - [[InlineKeyboardButton("🗑 Close", callback_data="cls")]] -) - - -@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): - - keyboard = InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton( - text="• Mᴇɴᴜ", callback_data="cbmenu" - ), - InlineKeyboardButton( - text="• Cʟᴏsᴇ", callback_data="cls" - ), - ] - ] - ) - - 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: - await m.reply_photo( - photo=f"{op[5]}", - caption=f"⏭ **Skipped to the next track.**\n\n🏷 **Name:** [{op[0]}]({op[1]})\n⏱ **Duration:** `{op[6]}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, - ) - else: - skip = m.text.split(None, 1)[1] - OP = "🗑 **removed song from queue:**" - if chat_id in QUEUE: - items = [int(x) for x in skip.split(" ") if x.isdigit()] - items.sort(reverse=True) - for x in items: - if x == 0: - pass - else: - hm = await skip_item(chat_id, x) - if hm == 0: - pass - else: - OP = OP + "\n" + f"**#{x}** - {hm}" - await m.reply(OP) - - -@Client.on_message( - command(["stop", f"stop@{BOT_USERNAME}", "end", f"end@{BOT_USERNAME}", "vstop"]) - & other_filters -) -@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): - if query.message.sender_chat: - return await query.answer("you're an Anonymous Admin !\n\n» revert back to user account from admin rights.") - 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 voice chats 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.edit_message_text( - "⏸ the streaming has paused", reply_markup=bttn - ) - except Exception as e: - await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=bcl) - else: - await query.answer("❌ nothing is currently streaming", show_alert=True) - - -@Client.on_callback_query(filters.regex("cbresume")) -async def cbresume(_, query: CallbackQuery): - if query.message.sender_chat: - return await query.answer("you're an Anonymous Admin !\n\n» revert back to user account from admin rights.") - 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 voice chats 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.edit_message_text( - "▶️ the streaming has resumed", reply_markup=bttn - ) - except Exception as e: - await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=bcl) - else: - await query.answer("❌ nothing is currently streaming", show_alert=True) - - -@Client.on_callback_query(filters.regex("cbstop")) -async def cbstop(_, query: CallbackQuery): - if query.message.sender_chat: - return await query.answer("you're an Anonymous Admin !\n\n» revert back to user account from admin rights.") - 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 voice chats 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=bcl) - except Exception as e: - await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=bcl) - else: - await query.answer("❌ nothing is currently streaming", show_alert=True) - - -@Client.on_callback_query(filters.regex("cbmute")) -async def cbmute(_, query: CallbackQuery): - if query.message.sender_chat: - return await query.answer("you're an Anonymous Admin !\n\n» revert back to user account from admin rights.") - 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 voice chats 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.edit_message_text( - "🔇 userbot succesfully muted", reply_markup=bttn - ) - except Exception as e: - await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=bcl) - else: - await query.answer("❌ nothing is currently streaming", show_alert=True) - - -@Client.on_callback_query(filters.regex("cbunmute")) -async def cbunmute(_, query: CallbackQuery): - if query.message.sender_chat: - return await query.answer("you're an Anonymous Admin !\n\n» revert back to user account from admin rights.") - 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 voice chats 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.edit_message_text( - "🔊 userbot succesfully unmuted", reply_markup=bttn - ) - except Exception as e: - await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=bcl) - 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**") diff --git a/program/callback.py b/program/callback.py deleted file mode 100644 index 002bc27..0000000 --- a/program/callback.py +++ /dev/null @@ -1,202 +0,0 @@ -# Copyright (C) 2021 By VeezMusicProject - -from driver.queues import QUEUE -from pyrogram import Client, filters -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.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.edit_message_text( - f"""❓ **Basic Guide for using this bot:** - -1.) **First, add me to your group.** -2.) **Then, promote me as administrator and give all permissions except Anonymous Admin.** -3.) **After promoting me, type /reload in group to refresh the admin data.** -3.) **Add @{ASSISTANT_NAME} to your group or type /userbotjoin to invite her.** -4.) **Turn on the video chat first before start to play video/music.** -5.) **Sometimes, reloading the bot by using /reload command can help you to fix some problem.** - -📌 **If the userbot not joined to video chat, make sure if the video chat already turned on, or type /userbotleave then type /userbotjoin again.** - -💡 **If you have a follow-up questions about this bot, you can tell it on my support chat here: @{GROUP_SUPPORT}** - -⚡ __Powered by {BOT_NAME} A.I__""", - reply_markup=InlineKeyboardMarkup( - [[InlineKeyboardButton("🔙 Go Back", callback_data="cbstart")]] - ), - ) - - -@Client.on_callback_query(filters.regex("cbcmds")) -async def cbcmds(_, query: CallbackQuery): - 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.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 -» /uptime - show the bot uptime status -» /alive - show the bot alive info (in group) - -⚡️ __Powered by {BOT_NAME} AI__""", - reply_markup=InlineKeyboardMarkup( - [[InlineKeyboardButton("🔙 Go Back", callback_data="cbcmds")]] - ), - ) - - -@Client.on_callback_query(filters.regex("cbadmin")) -async def cbadmin(_, query: CallbackQuery): - await query.edit_message_text( - f"""🏮 here is the admin commands: - -» /pause - pause the stream -» /resume - resume the stream -» /skip - switch to next stream -» /stop - stop the streaming -» /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.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): - if query.message.sender_chat: - return await query.answer("you're an Anonymous Admin !\n\n» revert back to user account from admin rights.") - 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 voice chats permission that can tap this button !", show_alert=True) - chat_id = query.message.chat.id - if chat_id in QUEUE: - await query.edit_message_text( - f"⚙️ **settings of** {query.message.chat.title}\n\n⏸ : pause stream\n▶️ : resume stream\n🔇 : mute userbot\n🔊 : unmute userbot\n⏹ : stop stream", - reply_markup=InlineKeyboardMarkup( - [[ - InlineKeyboardButton("⏹", callback_data="cbstop"), - InlineKeyboardButton("⏸", callback_data="cbpause"), - InlineKeyboardButton("▶️", callback_data="cbresume"), - ],[ - InlineKeyboardButton("🔇", callback_data="cbmute"), - InlineKeyboardButton("🔊", callback_data="cbunmute"), - ],[ - InlineKeyboardButton("🗑 Close", callback_data="cls")], - ] - ), - ) - 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 voice chats permission that can tap this button !", show_alert=True) - await query.message.delete() diff --git a/program/downloader.py b/program/downloader.py deleted file mode 100644 index 125c1f3..0000000 --- a/program/downloader.py +++ /dev/null @@ -1,152 +0,0 @@ -# Copyright (C) 2021 By Veez Music-Project - -from __future__ import unicode_literals - -import asyncio -import math -import os -import time -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 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}"])) -async def lyrics(_, message): - try: - if len(message.command) < 2: - await message.reply_text("» **give a lyric name too.**") - return - query = message.text.split(None, 1)[1] - rep = await message.reply_text("🔎 **searching lyrics...**") - resp = requests.get( - f"https://api-tede.herokuapp.com/api/lirik?l={query}" - ).json() - result = f"{resp['data']}" - await rep.edit(result) - except Exception: - await rep.edit("❌ **results of lyric not found.**\n\n» **please give a valid song name.**") diff --git a/program/inline.py b/program/inline.py deleted file mode 100644 index a54377f..0000000 --- a/program/inline.py +++ /dev/null @@ -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="", - ) diff --git a/program/music.py b/program/music.py deleted file mode 100644 index a635c5c..0000000 --- a/program/music.py +++ /dev/null @@ -1,277 +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 ASSISTANT_NAME, BOT_USERNAME, IMG_1, IMG_2 -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 pyrogram import Client -from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message -from pytgcalls import StreamType -from pytgcalls.types.input_stream import AudioPiped -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(format: str, link: str): - stdout, stderr = await bash(f'youtube-dl -g -f "{format}" {link}') - if stdout: - return 1, stdout.split("\n")[0] - 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 - keyboard = InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton(text="• Mᴇɴᴜ", callback_data="cbmenu"), - InlineKeyboardButton(text="• Cʟᴏsᴇ", callback_data="cls"), - ] - ] - ) - 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» ❌ __Add users__\n» ❌ __Add new Admins__\n» ❌ __Manage video chat__\n\nData is **updated** automatically after you **promote me**" - ) - return - if not a.can_manage_voice_chats: - await m.reply_text( - "missing required permission:" + "\n\n» ❌ __Manage video chat__" - ) - return - if not a.can_delete_messages: - await m.reply_text( - "missing required permission:" + "\n\n» ❌ __Delete messages__" - ) - return - if not a.can_invite_users: - await m.reply_text("missing required permission:" + "\n\n» ❌ __Add users__") - return - if not a.can_promote_members: - await m.reply_text("missing required permission:" + "\n\n» ❌ __Add new Admins__") - 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) - await m.chat.promote_member( - ubot, can_manage_voice_chats=True - ) - except UserNotParticipant: - try: - ubot = (await user.get_me()).id - 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) - await m.chat.promote_member( - ubot, can_manage_voice_chats=True - ) - 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 - if replied.audio: - if replied.audio.title: - songname = replied.audio.title[:70] - else: - if replied.audio.file_name: - songname = replied.audio.file_name[:70] - else: - songname = "Audio" - elif replied.voice: - songname = "Voice Note" - if chat_id in QUEUE: - pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0) - await suhu.delete() - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({link}) | `music`\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}", - reply_markup=keyboard, - ) - 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() - requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" - await m.reply_photo( - photo=f"{IMG_2}", - caption=f"🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Music`", - reply_markup=keyboard, - ) - 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) - 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, image, duration, "Audio", 0 - ) - await suhu.delete() - requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" - await m.reply_photo( - photo=image, - caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🎧 **Request by:** {requester}", - reply_markup=keyboard, - ) - else: - try: - await suhu.edit("🔄 **Joining vc...**") - await call_py.join_group_call( - chat_id, - AudioPiped( - ytlink, - ), - stream_type=StreamType().local_stream, - ) - add_to_queue(chat_id, songname, ytlink, url, image, duration, "Audio", 0) - await suhu.delete() - requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" - await m.reply_photo( - photo=image, - caption=f"🏷 **Name:** [{songname}]({url})\n**⏱ Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Music`", - reply_markup=keyboard, - ) - 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, image, duration, "Audio", 0) - await suhu.delete() - requester = ( - f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" - ) - await m.reply_photo( - photo=image, - caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🎧 **Request by:** {requester}", - reply_markup=keyboard, - ) - else: - try: - await suhu.edit("🔄 **Joining vc...**") - await call_py.join_group_call( - chat_id, - AudioPiped( - ytlink, - ), - stream_type=StreamType().local_stream, - ) - add_to_queue(chat_id, songname, ytlink, url, image, duration, "Audio", 0) - await suhu.delete() - requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" - await m.reply_photo( - photo=image, - caption=f"🏷 **Name:** [{songname}]({url})\n**⏱ Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Music`", - reply_markup=keyboard, - ) - except Exception as ep: - await suhu.delete() - await m.reply_text(f"🚫 error: `{ep}`") diff --git a/program/playlist.py b/program/playlist.py deleted file mode 100644 index 9f39444..0000000 --- a/program/playlist.py +++ /dev/null @@ -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.**") diff --git a/program/rmtrash.py b/program/rmtrash.py deleted file mode 100644 index 54649f0..0000000 --- a/program/rmtrash.py +++ /dev/null @@ -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**") diff --git a/program/start.py b/program/start.py deleted file mode 100644 index 0a54878..0000000 --- a/program/start.py +++ /dev/null @@ -1,164 +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(client: Client, message: Message): - 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✨ Bot is working normally\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 message.reply_photo( - 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}") - ] - ] - ) - ) diff --git a/program/sysinfo.py b/program/sysinfo.py deleted file mode 100644 index 9b65102..0000000 --- a/program/sysinfo.py +++ /dev/null @@ -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}` -**PlatFork - 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) diff --git a/program/updater.py b/program/updater.py deleted file mode 100644 index 3f78da5..0000000 --- a/program/updater.py +++ /dev/null @@ -1,77 +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"updates for [{ac_br}]:" - 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💬 {c.count()} 🗓 [{c.committed_datetime.strftime(d_form)}]\n" - f"[{c.summary}] 👨‍💻 {c.author}" - ) - 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 -r requirements.txt") - execle(sys.executable, sys.executable, "main.py", environ) - return - await msg.edit("bot is **up-to-date** with [main](https://github.com/levina-lab/video-stream/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 diff --git a/program/userbot_tools.py b/program/userbot_tools.py deleted file mode 100644 index bf9c114..0000000 --- a/program/userbot_tools.py +++ /dev/null @@ -1,93 +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 -from driver.decorators import authorized_users_only, sudo_users_only - - -@Client.on_message( - command(["userbotjoin", f"userbotjoin@{BOT_USERNAME}"]) & ~filters.private & ~filters.bot -) -@authorized_users_only -async def join_chat(c: Client, m: Message): - chat_id = m.chat.id - try: - invite_link = await m.chat.export_invite_link() - if "+" in invite_link: - link_hash = (invite_link.replace("+", "")).split("t.me/")[1] - await user.join_chat(f"https://t.me/joinchat/{link_hash}") - await m.chat.promote_member( - (await user.get_me()).id, - can_manage_voice_chats=True - ) - return await user.send_message(chat_id, "✅ userbot entered chat") - except UserAlreadyParticipant: - admin = await m.chat.get_member((await user.get_me()).id) - if not admin.can_manage_voice_chats: - await m.chat.promote_member( - (await user.get_me()).id, - can_manage_voice_chats=True - ) - return await user.send_message(chat_id, "✅ userbot already in chat") - return await user.send_message(chat_id, "✅ userbot already in chat") - - -@Client.on_message(command(["userbotleave", - f"leave@{BOT_USERNAME}"]) & filters.group & ~filters.edited -) -@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 - lol = await message.reply("🔄 **userbot** leaving all chats !") - async for dialog in user.iter_dialogs(): - try: - await user.leave_chat(dialog.chat.id) - left += 1 - await lol.edit( - f"Userbot leaving all group...\n\nLeft: {left} chats.\nFailed: {failed} chats." - ) - except BaseException: - failed += 1 - await lol.edit( - f"Userbot leaving...\n\nLeft: {left} chats.\nFailed: {failed} chats." - ) - await asyncio.sleep(0.7) - 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) diff --git a/program/video.py b/program/video.py deleted file mode 100644 index fb955b4..0000000 --- a/program/video.py +++ /dev/null @@ -1,461 +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 ASSISTANT_NAME, BOT_USERNAME, IMG_1, IMG_2 -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 InlineKeyboardButton, 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 - keyboard = InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton(text="• Mᴇɴᴜ", callback_data="cbmenu"), - InlineKeyboardButton(text="• Cʟᴏsᴇ", callback_data="cls"), - ] - ] - ) - 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» ❌ __Add users__\n» ❌ __Add new Admins__\n» ❌ __Manage video chat__\n\nData is **updated** automatically after you **promote me**" - ) - return - if not a.can_manage_voice_chats: - await m.reply_text( - "missing required permission:" + "\n\n» ❌ __Manage video chat__" - ) - return - if not a.can_delete_messages: - await m.reply_text( - "missing required permission:" + "\n\n» ❌ __Delete messages__" - ) - return - if not a.can_invite_users: - await m.reply_text("missing required permission:" + "\n\n» ❌ __Add users__") - return - if not a.can_promote_members: - await m.reply_text("missing required permission:" + "\n\n» ❌ __Add new Admins__") - 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) - await m.chat.promote_member( - ubot, can_manage_voice_chats=True - ) - except UserNotParticipant: - try: - ubot = (await user.get_me()).id - 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) - await m.chat.promote_member( - ubot, can_manage_voice_chats=True - ) - 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] - elif replied.document: - songname = replied.document.file_name[:70] - 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})" - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({link}) | `video`\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {requester}", - reply_markup=keyboard, - ) - 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})" - await m.reply_photo( - photo=f"{IMG_2}", - caption=f"🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Video`", - reply_markup=keyboard, - ) - else: - if len(m.command) < 2: - await m.reply( - "» reply to an **video file** or **give something to search.**" - ) - else: - loser = await 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, image, duration, "Video", Q - ) - await loser.delete() - requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" - await m.reply_photo( - photo=image, - caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🎧 **Request by:** {requester}", - reply_markup=keyboard, - ) - 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, image, duration, "Video", Q) - await loser.delete() - requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" - await m.reply_photo( - photo=image, - caption=f"🏷 **Name:** [{songname}]({url})\n⏱ **Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Video`", - reply_markup=keyboard, - ) - 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, image, duration, "Video", Q) - await loser.delete() - requester = ( - f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" - ) - await m.reply_photo( - photo=image, - caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🎧 **Request by:** {requester}", - reply_markup=keyboard, - ) - 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, image, duration, "Video", Q) - await loser.delete() - requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" - await m.reply_photo( - photo=image, - caption=f"🏷 **Name:** [{songname}]({url})\n⏱ **Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}\n📹 **Stream type:** `Video`", - reply_markup=keyboard, - ) - 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 - keyboard = InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton(text="• Mᴇɴᴜ", callback_data="cbmenu"), - InlineKeyboardButton(text="• Cʟᴏsᴇ", callback_data="cls"), - ] - ] - ) - 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» ❌ __Add users__\n» ❌ __Manage video chat__\n\nData is **updated** automatically after you **promote me**" - ) - return - if not a.can_manage_voice_chats: - await m.reply_text( - "missing required permission:" + "\n\n» ❌ __Manage video chat__" - ) - return - if not a.can_delete_messages: - await m.reply_text( - "missing required permission:" + "\n\n» ❌ __Delete messages__" - ) - return - if not a.can_invite_users: - await m.reply_text("missing required permission:" + "\n\n» ❌ __Add users__") - return - if not a.can_promote_members: - await m.reply_text("missing required permission:" + "\n\n» ❌ __Add new Admins__") - 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) - await m.chat.promote_member( - ubot, can_manage_voice_chats=True - ) - except UserNotParticipant: - try: - ubot = (await user.get_me()).id - 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) - await m.chat.promote_member( - ubot, can_manage_voice_chats=True - ) - 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})" - await m.reply_photo( - photo=f"{IMG_1}", - caption=f"💡 **Track added to queue »** `{pos}`\n\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {requester}", - reply_markup=keyboard, - ) - 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})" - ) - await m.reply_photo( - photo=f"{IMG_2}", - caption=f"💡 **[Video live]({link}) stream started.**\n\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}", - reply_markup=keyboard, - ) - except Exception as ep: - await loser.delete() - await m.reply_text(f"🚫 error: `{ep}`") diff --git a/program/ytsearch.py b/program/ytsearch.py deleted file mode 100644 index 1042d52..0000000 --- a/program/ytsearch.py +++ /dev/null @@ -1,50 +0,0 @@ -import logging -from config import BOT_USERNAME -from driver.filters import command, other_filters -from pyrogram import Client -from pyrogram.types import ( - InlineKeyboardButton, - InlineKeyboardMarkup, - Message, -) -from youtube_search import YoutubeSearch - -logging.basicConfig( - level=logging.DEBUG, - format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") -logger = logging.getLogger(__name__) -logging.getLogger("pyrogram").setLevel(logging.WARNING) - - -@Client.on_message(command(["search", f"search@{BOT_USERNAME}"])) -async def ytsearch(_, message: Message): - - keyboard = InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton( - "🗑 Close", callback_data="cls", - ) - ] - ] - ) - - try: - if len(message.command) < 2: - await message.reply_text("/search **needs an argument !**") - return - query = message.text.split(None, 1)[1] - m = await message.reply_text("🔎 **Searching...**") - results = YoutubeSearch(query, max_results=5).to_dict() - i = 0 - text = "" - while i < 5: - 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" - i += 1 - await m.edit(text, reply_markup=keyboard, disable_web_page_preview=True) - except Exception as e: - await m.edit(str(e))