From 5c68699e2c41e39f4b0bb5681bef91341bc7ea1f Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 23 Jan 2022 19:41:37 +0700 Subject: [PATCH 01/48] create database --- driver/database/dbchat.py | 38 +++++++++++++++++++++++++++++++++++++ driver/database/dblocal.py | 8 ++++++++ driver/database/dbpunish.py | 32 +++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 driver/database/dbchat.py create mode 100644 driver/database/dblocal.py create mode 100644 driver/database/dbpunish.py diff --git a/driver/database/dbchat.py b/driver/database/dbchat.py new file mode 100644 index 0000000..1b881c5 --- /dev/null +++ b/driver/database/dbchat.py @@ -0,0 +1,38 @@ +""" chat database """ + +from typing import Dict, List, Union + +from driver.database.dblocal import db + +chatsdb = db.chats + + +async def get_served_chats() -> list: + chats = chatsdb.find({"chat_id": {"$lt": 0}}) + if not chats: + return [] + chats_list = [] + for chat in await chats.to_list(length=1000000000): + chats_list.append(chat) + return chats_list + + +async def is_served_chat(chat_id: int) -> bool: + chat = await chatsdb.find_one({"chat_id": chat_id}) + if not chat: + return False + return True + + +async def add_served_chat(chat_id: int): + is_served = await is_served_chat(chat_id) + if is_served: + return + return await chatsdb.insert_one({"chat_id": chat_id}) + + +async def remove_served_chat(chat_id: int): + is_served = await is_served_chat(chat_id) + if not is_served: + return + return await chatsdb.delete_one({"chat_id": chat_id}) diff --git a/driver/database/dblocal.py b/driver/database/dblocal.py new file mode 100644 index 0000000..c1e4d9f --- /dev/null +++ b/driver/database/dblocal.py @@ -0,0 +1,8 @@ +""" mongo database """ + +from motor.motor_asyncio import AsyncIOMotorClient as Bot +from config import MONGO_DB_URI as tmo + + +MONGODB_CLI = Bot(tmo) +db = MONGODB_CLI.program diff --git a/driver/database/dbpunish.py b/driver/database/dbpunish.py new file mode 100644 index 0000000..029fe1c --- /dev/null +++ b/driver/database/dbpunish.py @@ -0,0 +1,32 @@ +from typing import Dict, List, Union + +from driver.database.dblocal import db + +gbansdb = db.gban + + +async def get_gbans_count() -> int: + users = gbansdb.find({"user_id": {"$gt": 0}}) + users = await users.to_list(length=100000) + return len(users) + + +async def is_gbanned_user(user_id: int) -> bool: + user = await gbansdb.find_one({"user_id": user_id}) + if not user: + return False + return True + + +async def add_gban_user(user_id: int): + is_gbanned = await is_gbanned_user(user_id) + if is_gbanned: + return + return await gbansdb.insert_one({"user_id": user_id}) + + +async def remove_gban_user(user_id: int): + is_gbanned = await is_gbanned_user(user_id) + if not is_gbanned: + return + return await gbansdb.delete_one({"user_id": user_id}) From 64762cea0e30443cf92e1a3e658c800f820c72de Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 23 Jan 2022 19:45:37 +0700 Subject: [PATCH 02/48] create broadcast --- program/extra.py | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 program/extra.py diff --git a/program/extra.py b/program/extra.py new file mode 100644 index 0000000..782c50c --- /dev/null +++ b/program/extra.py @@ -0,0 +1,112 @@ +""" broadcast & statistic collector """ + +import asyncio +from pyrogram import Client, filters +from pyrogram.types import Message +from driver.filters import command +from driver.decorators import sudo_users_only +from driver.database.dbchat import get_served_chats + +from config import BOT_USERNAME as bn + + +@Client.on_message(command(["broadcast", f"broadcast@{bn}"]) & ~filters.edited) +@sudo_users_only +async def broadcast(c: Client, message: Message): + if not message.reply_to_message: + pass + else: + x = message.reply_to_message.message_id + y = message.chat.id + sent = 0 + chats = [] + schats = await get_served_chats() + for chat in schats: + chats.append(int(chat["chat_id"])) + for i in chats: + try: + m = await c.forward_messages(i, y, x) + await asyncio.sleep(0.3) + sent += 1 + except Exception: + pass + await message.reply_text(f"✅ Broadcast complete in {sent} Group.") + return + if len(message.command) < 2: + await message.reply_text( + "**usage**:\n\n/broadcast (`message`) or (`reply to message`)" + ) + return + text = message.text.split(None, 1)[1] + sent = 0 + chats = [] + schats = await get_served_chats() + for chat in schats: + chats.append(int(chat["chat_id"])) + for i in chats: + try: + m = await c.send_message(i, text=text) + await asyncio.sleep(0.3) + sent += 1 + except Exception: + pass + await message.reply_text(f"✅ Broadcast complete in {sent} Group.") + + +@Client.on_message(command(["broadcast_pin", f"broadcast_pin@{bn}"]) & ~filters.edited) +@sudo_users_only +async def broadcast_pin(c: Client, message: Message): + if not message.reply_to_message: + pass + else: + x = message.reply_to_message.message_id + y = message.chat.id + sent = 0 + pin = 0 + chats = [] + schats = await get_served_chats() + for chat in schats: + chats.append(int(chat["chat_id"])) + for i in chats: + try: + m = await c.forward_messages(i, y, x) + try: + await m.pin(disable_notification=True) + pin += 1 + except Exception: + pass + await asyncio.sleep(0.3) + sent += 1 + except Exception: + pass + await message.reply_text( + f"✅ Broadcast complete in {sent} Group.\n📌 With the {pin} pins." + ) + return + if len(message.command) < 2: + await message.reply_text( + "**usage**:\n\n/broadcast (`message`) or (`reply to message`)" + ) + return + text = message.text.split(None, 1)[1] + sent = 0 + pin = 0 + chats = [] + schats = await get_served_chats() + for chat in schats: + chats.append(int(chat["chat_id"])) + for i in chats: + try: + m = await c.send_message(i, text=text) + try: + await m.pin(disable_notification=True) + pin += 1 + except Exception: + pass + await asyncio.sleep(0.3) + sent += 1 + except Exception: + pass + await message.reply_text( + f"✅ Broadcast complete in {sent} Group.\n📌 With the {pin} pins." + ) From 0dc7a990c4a8adce82e87a56b2cc5607b3b455e9 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 23 Jan 2022 21:52:45 +0700 Subject: [PATCH 03/48] create punishment --- program/punishment.py | 172 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 program/punishment.py diff --git a/program/punishment.py b/program/punishment.py new file mode 100644 index 0000000..fdb33e4 --- /dev/null +++ b/program/punishment.py @@ -0,0 +1,172 @@ +""" global banned and un-global banned module """ + +import asyncio + +from pyrogram import Client, filters +from pyrogram.types import Message +from driver.filters import command +from driver.decorators import sudo_users_only +from driver.database.dbchat import get_served_chats +from driver.database.dbpunish import add_gban_user, is_gbanned_user, remove_gban_user + +from config import BOT_NAME, SUDO_USERS, BOT_USERNAME as bn + + +@Client.on_message(command(["gban", f"gban@{bn}"]) & ~filters.edited) +@sudo_users_only +async def global_banned(c: Client, message: Message): + if not message.reply_to_message: + if len(message.command) < 2: + await message.reply_text("**usage:**\n\n/gban [username | user_id]") + return + user = message.text.split(None, 2)[1] + if "@" in user: + user = user.replace("@", "") + user = await c.get_users(user) + from_user = message.from_user + BOT_ID = await c.get_me() + if user.id == from_user.id: + return await message.reply_text( + "You can't gban yourself !" + ) + elif user.id == BOT_ID: + await message.reply_text("I can't gban myself !") + elif user.id in SUDO_USERS: + await message.reply_text("You can't gban sudo user !") + else: + await add_gban_user(user.id) + served_chats = [] + chats = await get_served_chats() + for chat in chats: + served_chats.append(int(chat["chat_id"])) + m = await message.reply_text( + f"🚷 **Globally banning {user.mention}**\n⏱ Expected time: `{len(served_chats)}`" + ) + number_of_chats = 0 + for num in served_chats: + try: + await c.ban_chat_member(num, user.id) + number_of_chats += 1 + await asyncio.sleep(1) + except FloodWait as e: + await asyncio.sleep(int(e.x)) + except Exception: + pass + ban_text = f""" +🚷 **New Global ban on [{BOT_NAME}](https://t.me/{bn}) + +**Origin:** {message.chat.title} [`{message.chat.id}`] +**Sudo User:** {from_user.mention} +**Banned User:** {user.mention} +**Banned User ID:** `{user.id}` +**Chats:** `{number_of_chats}`""" + try: + await m.delete() + except Exception: + pass + await message.reply_text( + f"{ban_text}", + disable_web_page_preview=True, + ) + return + from_user_id = message.from_user.id + from_user_mention = message.from_user.mention + user_id = message.reply_to_message.from_user.id + mention = message.reply_to_message.from_user.mention + BOT_ID = await c.get_me() + if user_id == from_user_id: + await message.reply_text("You can't gban yourself !") + elif user_id == BOT_ID: + await message.reply_text("I can't gban myself !") + elif user_id in SUDO_USERS: + await message.reply_text("You can't gban sudo user !") + else: + is_gbanned = await is_gbanned_user(user_id) + if is_gbanned: + await message.reply_text("This user already gbanned !") + else: + await add_gban_user(user_id) + served_chats = [] + chats = await get_served_chats() + for chat in chats: + served_chats.append(int(chat["chat_id"])) + m = await message.reply_text( + f"🚷 **Globally banning {mention}**\n⏱ Expected time: `{len(served_chats)}`" + ) + number_of_chats = 0 + for num in served_chats: + try: + await c.ban_chat_member(num, user_id) + number_of_chats += 1 + await asyncio.sleep(1) + except FloodWait as e: + await asyncio.sleep(int(e.x)) + except Exception: + pass + ban_text = f""" +🚷 **New Global ban on [{BOT_NAME}](https://t.me/{bn}) + +**Origin:** {message.chat.title} [`{message.chat.id}`] +**Sudo User:** {from_user_mention} +**Banned User:** {mention} +**Banned User ID:** `{user_id}` +**Chats:** `{number_of_chats}`""" + try: + await m.delete() + except Exception: + pass + await message.reply_text( + f"{ban_text}", + disable_web_page_preview=True, + ) + return + + +@Client.on_message(command(["ungban", f"ungban@{bn}"]) & ~filters.edited) +@sudo_users_only +async def ungban_global(c: Client, message: Message): + if not message.reply_to_message: + if len(message.command) != 2: + await message.reply_text( + "**usage:**\n\n/ungban [username | user_id]" + ) + return + user = message.text.split(None, 1)[1] + if "@" in user: + user = user.replace("@", "") + user = await c.get_users(user) + from_user = message.from_user + BOT_ID = await c.get_me() + if user.id == from_user.id: + await message.reply_text("You can't ungban yourself because you can't be gbanned !") + elif user.id == BOT_ID: + await message.reply_text("I can't ungban myself because i can't be gbanned !") + elif user.id in SUDO_USERS: + await message.reply_text("Sudo users can't be gbanned/ungbanned !") + else: + is_gbanned = await is_gbanned_user(user.id) + if not is_gbanned: + await message.reply_text("This user already ungbanned.") + else: + await remove_gban_user(user.id) + await message.reply_text("✅ This user has ungbanned.") + return + from_user_id = message.from_user.id + user_id = message.reply_to_message.from_user.id + mention = message.reply_to_message.from_user.mention + BOT_ID = await c.get_me() + if user_id == from_user_id: + await message.reply_text("You can't ungban yourself because you can't be gbanned !") + elif user_id == BOT_ID: + await message.reply_text( + "I can't ungban myself because i can't be gbanned !" + ) + elif user_id in sudoers: + await message.reply_text("Sudo users can't be gbanned/ungbanned !") + else: + is_gbanned = await is_gbanned_user(user_id) + if not is_gbanned: + await message.reply_text("This user already un-gbanned") + else: + await remove_gban_user(user_id) + await message.reply_text("✅ This user has ungbanned.") \ No newline at end of file From c0df9bfdb2426c0e5c6c2e4e3afcbfa7ecbedb04 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 23 Jan 2022 21:58:43 +0700 Subject: [PATCH 04/48] mongo var --- config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/config.py b/config.py index 6bc5da3..29f300c 100644 --- a/config.py +++ b/config.py @@ -12,6 +12,7 @@ BOT_TOKEN = getenv("BOT_TOKEN") BOT_NAME = getenv("BOT_NAME", "Video Stream") API_ID = int(getenv("API_ID")) API_HASH = getenv("API_HASH") +MONGODB_URL = getenv("MONGODB_URL") OWNER_NAME = getenv("OWNER_NAME", "dlwrml") ALIVE_NAME = getenv("ALIVE_NAME", "Levina") BOT_USERNAME = getenv("BOT_USERNAME", "veezvideobot") From 0355c49ec7556f6b6ddb808c47ee23b3a038ada0 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 23 Jan 2022 21:59:45 +0700 Subject: [PATCH 05/48] miss --- driver/database/dblocal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/database/dblocal.py b/driver/database/dblocal.py index c1e4d9f..9d1856f 100644 --- a/driver/database/dblocal.py +++ b/driver/database/dblocal.py @@ -1,7 +1,7 @@ """ mongo database """ from motor.motor_asyncio import AsyncIOMotorClient as Bot -from config import MONGO_DB_URI as tmo +from config import MONGODB_URL as tmo MONGODB_CLI = Bot(tmo) From e08a743d64d5941cfea65a6aeaa0d004ffb1d4ec Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 23 Jan 2022 22:06:03 +0700 Subject: [PATCH 06/48] add var --- app.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app.json b/app.json index 36537fb..b19ccc0 100644 --- a/app.json +++ b/app.json @@ -3,9 +3,12 @@ "description": "Telegram bot for Streaming Video & Music trought the Telegram Group Video Chat, powered by pytgcalls and pyrogram", "logo": "https://telegra.ph/file/1c41ded2dd871eb36bd7e.png", "keywords": [ - "pytgcalls", + "py-tgcalls", "telegram bot", "video stream", + "live stream", + "music stream", + "mongodb", "pyrogram" ], "website": "https://t.me/levinachannel", @@ -40,10 +43,15 @@ "description": "fill with the pyrogram String Session", "required": true }, - "SUDO_USERS": { - "description": "list of user ids to be added to sudo member list, or just fill with your id", + "MONGODB_URL": { + "description": "fill with the mongodb url you created from cloud.mongodb.com (tutorial about how to make it, find it on @VeezSupportGroup)", "required": true }, + "SUDO_USERS": { + "description": "list of user id to be added to sudo member list, or just fill with your id", + "required": true, + "value": "1757169682" + }, "GROUP_SUPPORT": { "description": "if you have group, then fill the group username here without @", "required": true, From 2180fa2adc986a2f6940d75794e85da29fc56384 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 23 Jan 2022 22:07:16 +0700 Subject: [PATCH 07/48] none --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index b19ccc0..55184af 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,6 @@ { "name": "Video x Music Stream Bot", - "description": "Telegram bot for Streaming Video & Music trought the Telegram Group Video Chat, powered by pytgcalls and pyrogram", + "description": "Telegram bot for Streaming Video & Music trought the Telegram Group Video Chat, powered by PyTgCalls and Pyrogram", "logo": "https://telegra.ph/file/1c41ded2dd871eb36bd7e.png", "keywords": [ "py-tgcalls", From 8256e72f389862f33d7f8a51eb594effce8f7c65 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 23 Jan 2022 22:09:29 +0700 Subject: [PATCH 08/48] new var --- example.env | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/example.env b/example.env index fdf2ce4..7f9e586 100644 --- a/example.env +++ b/example.env @@ -2,19 +2,19 @@ SESSION_NAME= Your Session # Your music bot username -BOT_USERNAME= +BOT_USERNAME= # Your Bot Token -BOT_TOKEN= +BOT_TOKEN= # Your music bot name -BOT_NAME= +BOT_NAME= # Your API ID from my.telegram.org -API_ID= +API_ID= # Your API HASH from my.telegram.org -API_HASH= +API_HASH= # List of user IDs separated by space (you can fill this with your id too) SUDO_USERS=1757169682 1670523611 1727937540 @@ -23,16 +23,19 @@ SUDO_USERS=1757169682 1670523611 1727937540 DURATION_LIMIT=240 # if you have channel, fill the channel username here without @ -UPDATES_CHANNEL=levinachannel +UPDATES_CHANNEL=levinachannel # # if you have group, fill the group username here without @ -GROUP_SUPPORT=VeezSupportGroup +GROUP_SUPPORT=VeezSupportGroup # fill with the assistant username without @ -ASSISTANT_NAME=veezassistant +ASSISTANT_NAME=VeezMusicAssistant # fill with username of your telegram account OWNER_NAME=dlwrml # fill with nickname/name of your telegram account -ALIVE_NAME=Levina \ No newline at end of file +ALIVE_NAME=Levina + +# fill with the mongodb url you created from cloud.mongodb.com +MONGODB_URL= From 0e26ac499676967e59f3cd2405203d7c55c0f807 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:25:34 +0700 Subject: [PATCH 09/48] removal --- config.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config.py b/config.py index 29f300c..9d346c3 100644 --- a/config.py +++ b/config.py @@ -9,21 +9,21 @@ load_dotenv() admins = {} SESSION_NAME = getenv("SESSION_NAME", "session") BOT_TOKEN = getenv("BOT_TOKEN") -BOT_NAME = getenv("BOT_NAME", "Video Stream") +BOT_NAME = getenv("BOT_NAME") API_ID = int(getenv("API_ID")) API_HASH = getenv("API_HASH") MONGODB_URL = getenv("MONGODB_URL") -OWNER_NAME = getenv("OWNER_NAME", "dlwrml") -ALIVE_NAME = getenv("ALIVE_NAME", "Levina") -BOT_USERNAME = getenv("BOT_USERNAME", "veezvideobot") -ASSISTANT_NAME = getenv("ASSISTANT_NAME", "cleo_invida") +OWNER_NAME = getenv("OWNER_NAME") +ALIVE_NAME = getenv("ALIVE_NAME") +BOT_USERNAME = getenv("BOT_USERNAME") +ASSISTANT_NAME = getenv("ASSISTANT_NAME") GROUP_SUPPORT = getenv("GROUP_SUPPORT", "VeezSupportGroup") UPDATES_CHANNEL = getenv("UPDATES_CHANNEL", "levinachannel") SUDO_USERS = list(map(int, getenv("SUDO_USERS").split())) COMMAND_PREFIXES = list(getenv("COMMAND_PREFIXES", "/ ! .").split()) ALIVE_IMG = getenv("ALIVE_IMG", "https://telegra.ph/file/c83b000f004f01897fe18.png") DURATION_LIMIT = int(getenv("DURATION_LIMIT", "60")) -UPSTREAM_REPO = getenv("UPSTREAM_REPO", "https://github.com/levina-lab/video-stream") +UPSTREAM_REPO = getenv("UPSTREAM_REPO") IMG_1 = getenv("IMG_1", "https://telegra.ph/file/d6f92c979ad96b2031cba.png") IMG_2 = getenv("IMG_2", "https://telegra.ph/file/6213d2673486beca02967.png") IMG_3 = getenv("IMG_3", "https://telegra.ph/file/f02efde766160d3ff52d6.png") From 24010eaadd1ea5f3c043bad768e65a1aa8279b08 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:32:38 +0700 Subject: [PATCH 10/48] add var --- app.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app.json b/app.json index 55184af..d73e680 100644 --- a/app.json +++ b/app.json @@ -28,7 +28,7 @@ "required": true }, "BOT_USERNAME": { - "description": "your bot username from @BotFather", + "description": "fill with your bot username from @BotFather but without using '@' symbol", "required": true }, "BOT_NAME": { @@ -52,6 +52,11 @@ "required": true, "value": "1757169682" }, + "UPSTREAM_REPO": { + "description": "This is needed for update feature, if you deployed forked repo put your forked repo link here, if not just leave it as it", + "required": true, + "value": "https://github.com/levina-lab/video-stream" + }, "GROUP_SUPPORT": { "description": "if you have group, then fill the group username here without @", "required": true, From 6a213c3ae2f8ad91cac7307f2924fdb6185a471d Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:39:05 +0700 Subject: [PATCH 11/48] none --- program/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/downloader.py b/program/downloader.py index 8375b1b..45c15cb 100644 --- a/program/downloader.py +++ b/program/downloader.py @@ -63,7 +63,7 @@ def song(_, message): info_dict = ydl.extract_info(link, download=False) audio_file = ydl.prepare_filename(info_dict) ydl.process_info(info_dict) - rep = f"**🎧 Uploader @{bn}**" + 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 From 4d9c97bdc5d1723f8542bba96123389effca818e Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:44:23 +0700 Subject: [PATCH 12/48] none --- program/speedtest.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/program/speedtest.py b/program/speedtest.py index a7f94bd..ab34b4b 100644 --- a/program/speedtest.py +++ b/program/speedtest.py @@ -1,5 +1,4 @@ # credit to TeamYukki for this speedtest module - import os import wget import speedtest @@ -14,20 +13,21 @@ from pyrogram.types import Message @Client.on_message(command(["speedtest", f"speedtest@{bname}"]) & ~filters.edited) -async def statsguwid(_, message: Message): - m = await message.reply_text("Running server speedtest.") +@sudo_users_only +async def run_speedtest(_, message: Message): + m = await message.reply_text("Running server speedtest -->") try: test = speedtest.Speedtest() test.get_best_server() - m = await m.edit("Running download speedtest..") + m = await m.edit("Running download speedtest --->") test.download() - m = await m.edit("Running upload speedtest...") + m = await m.edit("Running upload speedtest ---->") test.upload() test.results.share() result = test.results.dict() except Exception as e: return await m.edit(e) - m = await m.edit("Sharing speedtest results....") + m = await m.edit("🔄 Sharing speedtest results") path = wget.download(result["share"]) output = f"""💡 **SpeedTest Results** From bab76898826093bf82ccd3cfaeed0303cb3e1f00 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:50:09 +0700 Subject: [PATCH 13/48] cmd info --- program/callback.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/program/callback.py b/program/callback.py index f23efbd..ca510a7 100644 --- a/program/callback.py +++ b/program/callback.py @@ -85,7 +85,7 @@ 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 !** +» Choose the menu below to read the explanation & see the list of available Commands ! ⚡ __Powered by {BOT_NAME} A.I__""", reply_markup=InlineKeyboardMarkup( @@ -119,9 +119,8 @@ async def cbbasic(_, query: CallbackQuery): » /search (query) - search a youtube video link » /ping - show the bot ping status -» /speedtest - run the bot server speedtest » /uptime - show the bot uptime status -» /alive - show the bot alive info (in group) +» /alive - show the bot alive info (in Group only) ⚡️ __Powered by {BOT_NAME} AI__""", reply_markup=InlineKeyboardMarkup( @@ -159,8 +158,9 @@ 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 +» /gban (`username` or `user id`) - for global banned people +» /ungban (`username` or `user id`) - for un-global banned people +» /speedtest - run the bot server speedtest » /sysinfo - show the system information » /update - update your bot to latest version » /restart - restart your bot From db8ffaa2be45f39b2cf8bd32a0117c399ced993a Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:53:58 +0700 Subject: [PATCH 14/48] cmd info --- program/callback.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/program/callback.py b/program/callback.py index ca510a7..dbd4968 100644 --- a/program/callback.py +++ b/program/callback.py @@ -166,6 +166,9 @@ async def cbsudo(_, query: CallbackQuery): » /restart - restart your bot » /leaveall - order userbot to leave from all group +» /broadcast (`message`) - send a broadcast message to all groups entered by bot +» /broadcast_pin (`message`) - send a broadcast message to all groups entered by bot with the chat pin + ⚡ __Powered by {BOT_NAME} AI__""", reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("🔙 Go Back", callback_data="cbcmds")]] From 598e475f160040b03ae22eeb330e161eafd8344f Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:55:22 +0700 Subject: [PATCH 15/48] module deactivated --- program/{rmtrash.py => rmtrash} | 2 ++ 1 file changed, 2 insertions(+) rename program/{rmtrash.py => rmtrash} (93%) diff --git a/program/rmtrash.py b/program/rmtrash similarity index 93% rename from program/rmtrash.py rename to program/rmtrash index 54649f0..b5e8ff1 100644 --- a/program/rmtrash.py +++ b/program/rmtrash @@ -48,3 +48,5 @@ async def cleanup(_, message: Message): await message.reply_text("✅ **cleaned**") else: await message.reply_text("✅ **already cleaned**") + +# this module has deactivated because no longer used if you want to take the code just take it and use it, Thanks From 8f366ad2a406b861e398898f362a6cd915706fa9 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:05:59 +0700 Subject: [PATCH 16/48] add gban watcher --- program/start.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/program/start.py b/program/start.py index 7b99e55..b5c3679 100644 --- a/program/start.py +++ b/program/start.py @@ -14,6 +14,7 @@ from config import ( from program import __version__ from driver.veez import user from driver.filters import command, other_filters +from driver.database.dbpunish import is_gbanned_user from pyrogram import Client, filters from pyrogram import __version__ as pyrover from pytgcalls import (__version__ as pytover) @@ -164,3 +165,22 @@ async def new_chat(c: Client, m: Message): ] ) ) + + +chat_watcher_group = 5 + +@Client.on_message(group=chat_watcher_group) +async def chat_watcher_func(_, message: Message): + try: + userid = message.from_user.id + except Exception: + return + suspect = f"[{message.from_user.first_name}](tg://user?id={message.from_user.id})" + if await is_gbanned_user(userid): + try: + await message.chat.ban_member(userid) + except Exception: + return + await message.reply_text( + f"👮🏼 (> {suspect} <)\n\n**Gbanned** user joined, that user has been gbanned by sudo user and was blocked from this Chat !\n\n🚫 **Reason:** potential spammer and abuser." + ) From 8b1e384508922545246d7d1a5fb92c70292fc4c4 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:09:41 +0700 Subject: [PATCH 17/48] beta release stable version will released in next month ( February ) --- program/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/__init__.py b/program/__init__.py index 22049ab..4a13052 100644 --- a/program/__init__.py +++ b/program/__init__.py @@ -1 +1 @@ -__version__ = "0.6.2" +__version__ = "0.6.2 Beta" From 2d5e9ce8381c1faad079abfc62d83717377274ec Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 20:23:55 +0700 Subject: [PATCH 18/48] add duration info for local video --- program/video.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/program/video.py b/program/video.py index 746db9e..7fb19e2 100644 --- a/program/video.py +++ b/program/video.py @@ -135,8 +135,10 @@ async def vplay(c: Client, m: Message): try: if replied.video: songname = replied.video.file_name[:70] + duration = replied.video.duration elif replied.document: songname = replied.document.file_name[:70] + duration = replied.document.duration except BaseException: songname = "Video" @@ -148,7 +150,7 @@ async def vplay(c: Client, m: Message): await m.reply_photo( photo=f"{IMG_1}", reply_markup=InlineKeyboardMarkup(buttons), - caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `video`\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", + caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}", ) else: if Q == 720: @@ -174,7 +176,7 @@ async def vplay(c: Client, m: Message): await m.reply_photo( photo=f"{IMG_2}", reply_markup=InlineKeyboardMarkup(buttons), - caption=f"🗂 **Name:** [{songname}]({link}) | `video`\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", + caption=f"🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}", ) else: if len(m.command) < 2: From 135b90b32daecf60005d45b327181ad86f9b51f2 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 25 Jan 2022 21:01:19 +0700 Subject: [PATCH 19/48] add duration info for local audio --- program/music.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/program/music.py b/program/music.py index 13ac7d7..01de72e 100644 --- a/program/music.py +++ b/program/music.py @@ -109,16 +109,18 @@ async def play(c: Client, m: Message): suhu = await replied.reply("📥 **downloading audio...**") dl = await replied.download() link = replied.link - if replied.audio: - if replied.audio.title: + + try: + if replied.audio: 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" + songname = replied.audio.file_name[:70] + duration = replied.audio.duration + elif replied.voice: + songname = "Voice Note" + duration = replied.voice.duration + except BaseException: + songname = "Audio" + if chat_id in QUEUE: pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0) requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" @@ -127,7 +129,7 @@ async def play(c: Client, m: Message): await m.reply_photo( photo=f"{IMG_1}", reply_markup=InlineKeyboardMarkup(buttons), - caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `music`\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", + caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}", ) else: try: @@ -146,7 +148,7 @@ async def play(c: Client, m: Message): await m.reply_photo( photo=f"{IMG_2}", reply_markup=InlineKeyboardMarkup(buttons), - caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", + caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}", ) except Exception as e: await suhu.delete() From 2045d422d51aab9252086c758a9e73bd5d2f3fce Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Wed, 26 Jan 2022 19:58:22 +0700 Subject: [PATCH 20/48] none --- program/speedtest.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/program/speedtest.py b/program/speedtest.py index ab34b4b..2edbc9e 100644 --- a/program/speedtest.py +++ b/program/speedtest.py @@ -1,4 +1,5 @@ # credit to TeamYukki for this speedtest module + import os import wget import speedtest @@ -15,19 +16,20 @@ from pyrogram.types import Message @Client.on_message(command(["speedtest", f"speedtest@{bname}"]) & ~filters.edited) @sudo_users_only async def run_speedtest(_, message: Message): - m = await message.reply_text("Running server speedtest -->") + m = await message.reply_text("⚡️ running server speedtest") try: test = speedtest.Speedtest() test.get_best_server() - m = await m.edit("Running download speedtest --->") + m = await m.edit("⚡️ running download speedtest..") test.download() - m = await m.edit("Running upload speedtest ---->") + m = await m.edit("⚡️ running upload speedtest...") test.upload() test.results.share() result = test.results.dict() except Exception as e: - return await m.edit(e) - m = await m.edit("🔄 Sharing speedtest results") + await m.edit(e) + return + m = await m.edit("🔄 sharing speedtest results") path = wget.download(result["share"]) output = f"""💡 **SpeedTest Results** From efd76e142476a55fa0eecfaf611b940aaa9b06a9 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 30 Jan 2022 07:32:42 +0700 Subject: [PATCH 21/48] create developer plugin --- program/developer.py | 170 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 program/developer.py diff --git a/program/developer.py b/program/developer.py new file mode 100644 index 0000000..03ff098 --- /dev/null +++ b/program/developer.py @@ -0,0 +1,170 @@ +import os +import re +import sys +import shutil +import subprocess +import traceback + +from time import time +from io import StringIO +from sys import version as pyver +from inspect import getfullargspec + +from config import BOT_USERNAME as bname +from driver.filters import command, other_filters +from pyrogram import Client, filters +from driver.decorators import sudo_users_only, error +from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup + + +async def aexec(code, client, message): + exec( + "async def __aexec(client, message): " + + "".join(f"\n {a}" for a in code.split("\n")) + ) + return await locals()["__aexec"](client, message) + + +async def edit_or_reply(msg: Message, **kwargs): + func = msg.edit_text if msg.from_user.is_self else msg.reply + spec = getfullargspec(func.__wrapped__).args + await func(**{k: v for k, v in kwargs.items() if k in spec}) + + +@Client.on_message(command(["eval", f"eval{bname}"]) & other_filters) +@sudo_users_only +async def executor(client, message): + if len(message.command) < 2: + return await edit_or_reply(message, text="» Give a command to execute") + try: + cmd = message.text.split(" ", maxsplit=1)[1] + except IndexError: + return await message.delete() + t1 = time() + old_stderr = sys.stderr + old_stdout = sys.stdout + redirected_output = sys.stdout = StringIO() + redirected_error = sys.stderr = StringIO() + stdout, stderr, exc = None, None, None + try: + await aexec(cmd, client, message) + except Exception: + exc = traceback.format_exc() + stdout = redirected_output.getvalue() + stderr = redirected_error.getvalue() + sys.stdout = old_stdout + sys.stderr = old_stderr + evaluation = "" + if exc: + evaluation = exc + elif stderr: + evaluation = stderr + elif stdout: + evaluation = stdout + else: + evaluation = "SUCCESS" + final_output = f"`OUTPUT:`\n\n```{evaluation.strip()}```" + if len(final_output) > 4096: + filename = "output.txt" + with open(filename, "w+", encoding="utf8") as out_file: + out_file.write(str(evaluation.strip())) + t2 = time() + keyboard = InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton( + text="⏳", callback_data=f"runtime {t2-t1} Seconds" + ) + ] + ] + ) + await message.reply_document( + document=filename, + caption=f"`INPUT:`\n`{cmd[0:980]}`\n\n`OUTPUT:`\n`attached document`", + quote=False, + reply_markup=keyboard, + ) + await message.delete() + os.remove(filename) + else: + t2 = time() + keyboard = InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton( + text="⏳", + callback_data=f"runtime {round(t2-t1, 3)} Seconds", + ) + ] + ] + ) + await edit_or_reply(message, text=final_output, reply_markup=keyboard) + + +@Client.on_callback_query(filters.regex(r"runtime")) +async def runtime_func_cq(_, cq): + runtime = cq.data.split(None, 1)[1] + await cq.answer(runtime, show_alert=True) + + +@Client.on_message(command(["sh", f"sh{bname}"]) & other_filters) +@sudo_users_only +async def shellrunner(client, message): + if len(message.command) < 2: + return await edit_or_reply(message, text="**usage:**\n\n» /sh git pull") + text = message.text.split(None, 1)[1] + if "\n" in text: + code = text.split("\n") + output = "" + for x in code: + shell = re.split(""" (?=(?:[^'"]|'[^']*'|"[^"]*")*$)""", x) + try: + process = subprocess.Popen( + shell, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + except Exception as err: + print(err) + await edit_or_reply(message, text=f"`ERROR:`\n```{err}```") + output += f"**{code}**\n" + output += process.stdout.read()[:-1].decode("utf-8") + output += "\n" + else: + shell = re.split(""" (?=(?:[^'"]|'[^']*'|"[^"]*")*$)""", text) + for a in range(len(shell)): + shell[a] = shell[a].replace('"', "") + try: + process = subprocess.Popen( + shell, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + except Exception as err: + print(err) + exc_type, exc_obj, exc_tb = sys.exc_info() + errors = traceback.format_exception( + etype=exc_type, + value=exc_obj, + tb=exc_tb, + ) + return await edit_or_reply( + message, text=f"`ERROR:`\n```{''.join(errors)}```" + ) + output = process.stdout.read()[:-1].decode("utf-8") + if str(output) == "\n": + output = None + if output: + if len(output) > 4096: + with open("output.txt", "w+") as file: + file.write(output) + await app.send_document( + message.chat.id, + "output.txt", + reply_to_message_id=message.message_id, + caption="`OUTPUT`", + ) + return os.remove("output.txt") + await edit_or_reply(message, text=f"`OUTPUT:`\n```{output}```") + else: + await edit_or_reply(message, text="`OUTPUT:`\n`no output`") From 1f2358e7acc86109521aca851f526c9b34e12bec Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 30 Jan 2022 07:51:58 +0700 Subject: [PATCH 22/48] cmd leave chat --- program/developer.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/program/developer.py b/program/developer.py index 03ff098..96a7ed7 100644 --- a/program/developer.py +++ b/program/developer.py @@ -11,6 +11,7 @@ from sys import version as pyver from inspect import getfullargspec from config import BOT_USERNAME as bname +from driver.veez import bot from driver.filters import command, other_filters from pyrogram import Client, filters from driver.decorators import sudo_users_only, error @@ -24,7 +25,6 @@ async def aexec(code, client, message): ) return await locals()["__aexec"](client, message) - async def edit_or_reply(msg: Message, **kwargs): func = msg.edit_text if msg.from_user.is_self else msg.reply spec = getfullargspec(func.__wrapped__).args @@ -168,3 +168,21 @@ async def shellrunner(client, message): await edit_or_reply(message, text=f"`OUTPUT:`\n```{output}```") else: await edit_or_reply(message, text="`OUTPUT:`\n`no output`") + + +@Client.on_message(command(["leavebot", f"leavebot{bname}"]) & other_filters) +@sudo_users_only +async def bot_leave_group(_, message): + if len(message.command) != 2: + await message.reply_text( + "**usage:**\n\n» /leavebot [chat id]" + ) + return + chat = message.text.split(None, 2)[1] + try: + await bot.leave_chat(chat) + except Exception as e: + await message.reply_text(f"❌ procces failed\n\nreason: `{e}`") + print(e) + return + await message.reply_text(f"✅ Bot successfully left from chat: `{chat}`") From c0b93680c692094d584d187ab5f08bf9cefeeab5 Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:37:18 +0530 Subject: [PATCH 23/48] add audio quality --- program/music.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/program/music.py b/program/music.py index 01de72e..b1508de 100644 --- a/program/music.py +++ b/program/music.py @@ -12,6 +12,7 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message # pytgcalls stuff from pytgcalls import StreamType from pytgcalls.types.input_stream import AudioPiped +from pytgcalls.types.input_stream.quality import HighQualityAudio # repository stuff from program.utils.inline import stream_markup from driver.design.thumbnail import thumb @@ -40,7 +41,7 @@ def ytsearch(query: str): async def ytdl(format: str, link: str): - stdout, stderr = await bash(f'youtube-dl -g -f "{format}" {link}') + stdout, stderr = await bash(f'yt-dlp -g -f "{format}" {link}') if stdout: return 1, stdout.split("\n")[0] return 0, stderr @@ -138,6 +139,7 @@ async def play(c: Client, m: Message): chat_id, AudioPiped( dl, + HighQualityAudio(), ), stream_type=StreamType().local_stream, ) @@ -174,7 +176,7 @@ async def play(c: Client, m: Message): gcname = m.chat.title ctitle = await CHAT_TITLE(gcname) image = await thumb(thumbnail, title, userid, ctitle) - format = "bestaudio[ext=m4a]" + format = "bestaudio/best" veez, ytlink = await ytdl(format, url) if veez == 0: await suhu.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") @@ -198,6 +200,7 @@ async def play(c: Client, m: Message): chat_id, AudioPiped( ytlink, + HighQualityAudio(), ), stream_type=StreamType().local_stream, ) @@ -235,7 +238,7 @@ async def play(c: Client, m: Message): gcname = m.chat.title ctitle = await CHAT_TITLE(gcname) image = await thumb(thumbnail, title, userid, ctitle) - format = "bestaudio[ext=m4a]" + format = "bestaudio/best" veez, ytlink = await ytdl(format, url) if veez == 0: await suhu.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") @@ -257,6 +260,7 @@ async def play(c: Client, m: Message): chat_id, AudioPiped( ytlink, + HighQualityAudio(), ), stream_type=StreamType().local_stream, ) From ff2d251bea0d36d6d07021a86711187b7bdbacdf Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:39:11 +0530 Subject: [PATCH 24/48] add audio quality in audio calls also --- driver/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/driver/utils.py b/driver/utils.py index d3a1234..2b855c7 100644 --- a/driver/utils.py +++ b/driver/utils.py @@ -49,6 +49,7 @@ async def skip_current_song(chat_id): chat_id, AudioPiped( url, + HighQualityAudio(), ), ) elif type == "Video": @@ -59,7 +60,12 @@ async def skip_current_song(chat_id): elif Q == 360: hm = LowQualityVideo() await call_py.change_stream( - chat_id, AudioVideoPiped(url, HighQualityAudio(), hm) + chat_id, + AudioVideoPiped( + url, + HighQualityAudio(), + hm, + ), ) pop_an_item(chat_id) return [songname, link, type] From 4de05e8f180c3fd613b079bb9601d42045cd1cee Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:40:31 +0530 Subject: [PATCH 25/48] remove git link from deploy button --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f37d95b..79df8e0 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ ## Heroku Deployment 💜 The easy way to host this bot, deploy to Heroku, Change the app country to Europe (it will help to make the bot stable). -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/levina-lab/video-stream) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) ## VPS Deployment 📡 Get the best Quality of streaming performance by hosting it on VPS, here's the step's: @@ -95,7 +95,6 @@ python3 main.py # run the bot. - [Zxce3](https://github.com/Zxce3) ``Dev`` - [DoellBarr](https://github.com/DoellBarr) ``Dev`` - [tofikdn](https://github.com/tofikdn) ``Dev`` -- [Makoto-XD](https://github.com/Makoto-XD) ``Supporter`` - [Laky's](https://github.com/Laky-64) for [``py-tgcalls``](https://github.com/pytgcalls/pytgcalls) - [Dan](https://github.com/delivrance) for [``Pyrogram``](https://github.com/pyrogram) From 88c22dbb4ad6ce49720ffd605ab0178a892039f0 Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:42:53 +0530 Subject: [PATCH 26/48] okay --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 739a514..66be335 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,6 @@ pyrogram youtube-search-python yt-dlp speedtest-cli -git+https://github.com/ytdl-org/youtube-dl@master youtube-search python-dotenv dnspython From c606d54ff0f96514177f632820839d2a674b8448 Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:46:50 +0530 Subject: [PATCH 27/48] okay --- Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 36123be..c656865 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ -FROM nikolaik/python-nodejs:python3.9-nodejs17 +FROM nikolaik/python-nodejs:latest RUN apt-get update \ && apt-get install -y --no-install-recommends ffmpeg \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY . /app -WORKDIR /app +COPY . /app/ +WORKDIR /app/ RUN pip3 install --no-cache-dir --upgrade --requirement requirements.txt - CMD ["python3", "main.py"] From 5b0b939a071a89a4e4046d1b3bcf393c792b10a2 Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:48:01 +0530 Subject: [PATCH 28/48] useless file --- runtime.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 runtime.txt diff --git a/runtime.txt b/runtime.txt deleted file mode 100644 index f72c511..0000000 --- a/runtime.txt +++ /dev/null @@ -1 +0,0 @@ -python-3.9.0 From 14cd4b2eb9ffec41ec36504bdd70348261be26a0 Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:48:26 +0530 Subject: [PATCH 29/48] useless file --- Procfile | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Procfile diff --git a/Procfile b/Procfile deleted file mode 100644 index eb131d6..0000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -worker: python3 main.py From 953a0df54f8bd790f2af4cba9b2afb6d1a60cfc0 Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:49:08 +0530 Subject: [PATCH 30/48] add worker in yml file --- heroku.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/heroku.yml b/heroku.yml index cdeba04..5f17c5c 100644 --- a/heroku.yml +++ b/heroku.yml @@ -1,3 +1,5 @@ build: docker: - worker: Dockerfile + worker: Dockerfile +run: + worker: python3 main.py From d7d4af72285db15184101d679997ebae48267055 Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:50:26 +0530 Subject: [PATCH 31/48] umm --- .dockerignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index e9a0f31..f356d3f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,11 +3,8 @@ *.png .git/ .idea/ -str.py -Procfile README.md downloads/ raw_files/ .gitignore -runtime.txt __pycache__/ From 544b9fef94edece503cc866b55e9359ab15a0914 Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:51:00 +0530 Subject: [PATCH 32/48] umm --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8040e00..03d636a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ __pycache__ raw_files downloads venv -local.env *.jpg *png *.raw From 21b6fb9d5584fe90375e7ed040d91955f9dbcad9 Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:51:30 +0530 Subject: [PATCH 33/48] umm --- config.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/config.py b/config.py index 9d346c3..d5f8170 100644 --- a/config.py +++ b/config.py @@ -2,9 +2,6 @@ import os from os import getenv from dotenv import load_dotenv -if os.path.exists("local.env"): - load_dotenv("local.env") - load_dotenv() admins = {} SESSION_NAME = getenv("SESSION_NAME", "session") From 8c9844da153592b62e1b81bd3aa868bf8e4ada6f Mon Sep 17 00:00:00 2001 From: Hunter Opp <85411336+Hunter-Opp@users.noreply.github.com> Date: Mon, 31 Jan 2022 01:53:08 +0530 Subject: [PATCH 34/48] okay --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index c6a5f54..7a59c4b 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -9,7 +9,7 @@ jobs: strategy: max-parallel: 5 matrix: - python-version: [3.9] + python-version: [3.10] steps: - uses: actions/checkout@v1 From 16fa609017cbecec5a0dd25c2afd35579f041a45 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 03:39:39 +0700 Subject: [PATCH 35/48] wrong --- program/developer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/developer.py b/program/developer.py index 96a7ed7..cc58c88 100644 --- a/program/developer.py +++ b/program/developer.py @@ -14,7 +14,7 @@ from config import BOT_USERNAME as bname from driver.veez import bot from driver.filters import command, other_filters from pyrogram import Client, filters -from driver.decorators import sudo_users_only, error +from driver.decorators import sudo_users_only, errors from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup From 5f850666be4d945d3bd8411ec00291fa57d180cc Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 15:52:15 +0700 Subject: [PATCH 36/48] revision default github update --- .github/workflows/python-app.yml | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 7a59c4b..2cfc2a3 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -1,36 +1,36 @@ -name: FailCheck +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -on: [push, pull_request] +name: Python application + +on: + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] jobs: build: runs-on: ubuntu-latest - strategy: - max-parallel: 5 - matrix: - python-version: [3.10] steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + - uses: actions/checkout@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} + python-version: "3.10" - name: Install dependencies run: | - sudo apt-get install libpq-dev python -m pip install --upgrade pip - pip install -r requirements.txt - pip install flake8 flake8-print flake8-quotes - - name: Check for showstoppers + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 run: | - flake8 . --count --select=E999 --show-source --statistics - shellcheck: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Check for install script errors - uses: ludeeus/action-shellcheck@0.1.0 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest From a69111201c5b3df0042feb67988e634c6e56628c Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 15:55:22 +0700 Subject: [PATCH 37/48] none --- .github/workflows/python-app.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 2cfc2a3..28a9706 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -1,13 +1,13 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Python application +name: FailCheck on: push: - branches: [ $default-branch ] + branches: [ beta ] pull_request: - branches: [ $default-branch ] + branches: [ beta ] jobs: build: From 16a3e6f23c046d947985876f542556ad42f6beb0 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 15:58:22 +0700 Subject: [PATCH 38/48] miss --- program/developer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/developer.py b/program/developer.py index cc58c88..e9aad80 100644 --- a/program/developer.py +++ b/program/developer.py @@ -158,7 +158,7 @@ async def shellrunner(client, message): if len(output) > 4096: with open("output.txt", "w+") as file: file.write(output) - await app.send_document( + await bot.send_document( message.chat.id, "output.txt", reply_to_message_id=message.message_id, From 3e2fd8a8af973c0641cbd4cf8298de4bcefaa0d8 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 16:00:02 +0700 Subject: [PATCH 39/48] miss --- program/punishment.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/program/punishment.py b/program/punishment.py index fdb33e4..ae3129f 100644 --- a/program/punishment.py +++ b/program/punishment.py @@ -4,6 +4,7 @@ import asyncio from pyrogram import Client, filters from pyrogram.types import Message +from pyrogram.errors import FloodWait from driver.filters import command from driver.decorators import sudo_users_only from driver.database.dbchat import get_served_chats @@ -161,7 +162,7 @@ async def ungban_global(c: Client, message: Message): await message.reply_text( "I can't ungban myself because i can't be gbanned !" ) - elif user_id in sudoers: + elif user_id in SUDO_USERS: await message.reply_text("Sudo users can't be gbanned/ungbanned !") else: is_gbanned = await is_gbanned_user(user_id) @@ -169,4 +170,4 @@ async def ungban_global(c: Client, message: Message): await message.reply_text("This user already un-gbanned") else: await remove_gban_user(user_id) - await message.reply_text("✅ This user has ungbanned.") \ No newline at end of file + await message.reply_text("✅ This user has ungbanned.") From 1336c4fc59c54059e2eda7f5cf39093830857fad Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 16:03:26 +0700 Subject: [PATCH 40/48] revert --- .github/workflows/python-app.yml | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 28a9706..2f4a1be 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -1,36 +1,36 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: FailCheck -on: - push: - branches: [ beta ] - pull_request: - branches: [ beta ] +on: [push, pull_request] jobs: build: runs-on: ubuntu-latest + strategy: + max-parallel: 5 + matrix: + python-version: [3.10] steps: - uses: actions/checkout@v2 - - name: Set up Python 3.10 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Install dependencies run: | + sudo apt-get install libpq-dev python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 + pip install -r requirements.txt + pip install flake8 flake8-print flake8-quotes + - name: Check for showstoppers run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest + flake8 . --count --select=E999 --show-source --statistics + shellcheck: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Check for install script errors + uses: ludeeus/action-shellcheck@0.1.0 From 02b2dcd9244c760d6380ca4e192d5caebd781ebf Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 16:08:10 +0700 Subject: [PATCH 41/48] quote the version string default github update --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 2f4a1be..1153303 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -9,7 +9,7 @@ jobs: strategy: max-parallel: 5 matrix: - python-version: [3.10] + python-version: "3.10" steps: - uses: actions/checkout@v2 From f5f7aac1b67c780595dea72140d01cb59e49b2ac Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 16:15:53 +0700 Subject: [PATCH 42/48] don't change --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 1153303..72cb4f9 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -9,7 +9,7 @@ jobs: strategy: max-parallel: 5 matrix: - python-version: "3.10" + python-version: [3.9] steps: - uses: actions/checkout@v2 From d412688c0bfb19fcc3f2f1f5bd2c04f56dfea903 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 17:03:43 +0700 Subject: [PATCH 43/48] use youtube-dl --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 66be335..dd3760d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,9 @@ ffmpeg-python py-tgcalls pyrogram youtube-search-python +git+https://github.com/ytdl-org/youtube-dl@master yt-dlp +lyricsgenius speedtest-cli youtube-search python-dotenv @@ -18,4 +20,3 @@ motor psutil future wget -lyricsgenius From 4e473a0841d97c074ad8684e50e16b426076c4c6 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 17:04:26 +0700 Subject: [PATCH 44/48] use youtube-dl --- program/music.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/music.py b/program/music.py index b1508de..e6d34a1 100644 --- a/program/music.py +++ b/program/music.py @@ -41,7 +41,7 @@ def ytsearch(query: str): async def ytdl(format: str, link: str): - stdout, stderr = await bash(f'yt-dlp -g -f "{format}" {link}') + stdout, stderr = await bash(f'youtube-dl -g -f "{format}" {link}') if stdout: return 1, stdout.split("\n")[0] return 0, stderr From cdb84ec59a74a68c4441ab0e80f78e233c1ef387 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 17:11:01 +0700 Subject: [PATCH 45/48] none --- main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 5aa12d3..2962be8 100644 --- a/main.py +++ b/main.py @@ -2,11 +2,12 @@ import asyncio from pytgcalls import idle from driver.veez import call_py, bot + async def start_bot(): await bot.start() print("[INFO]: BOT & UBOT CLIENT STARTED !!") await call_py.start() - print("[INFO]: PYTGCALLS CLIENT STARTED !!") + print("[INFO]: PY-TGCALLS CLIENT STARTED !!") await idle() print("[INFO]: STOPPING BOT & USERBOT") await bot.stop() From 90b181c5a99a23ffdeae8a8f2fd40b87b03847d5 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 17:26:23 +0700 Subject: [PATCH 46/48] hum --- program/music.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/program/music.py b/program/music.py index e6d34a1..354ea67 100644 --- a/program/music.py +++ b/program/music.py @@ -176,7 +176,7 @@ async def play(c: Client, m: Message): gcname = m.chat.title ctitle = await CHAT_TITLE(gcname) image = await thumb(thumbnail, title, userid, ctitle) - format = "bestaudio/best" + format = "bestaudio[ext=m4a]" veez, ytlink = await ytdl(format, url) if veez == 0: await suhu.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") @@ -238,7 +238,7 @@ async def play(c: Client, m: Message): gcname = m.chat.title ctitle = await CHAT_TITLE(gcname) image = await thumb(thumbnail, title, userid, ctitle) - format = "bestaudio/best" + format = "bestaudio[ext=m4a]" veez, ytlink = await ytdl(format, url) if veez == 0: await suhu.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`") From 65c95060378b7552f96d56723e75d71435a358ac Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 18:09:14 +0700 Subject: [PATCH 47/48] revert --- program/music.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/program/music.py b/program/music.py index 354ea67..08b9c9f 100644 --- a/program/music.py +++ b/program/music.py @@ -200,7 +200,6 @@ async def play(c: Client, m: Message): chat_id, AudioPiped( ytlink, - HighQualityAudio(), ), stream_type=StreamType().local_stream, ) @@ -260,7 +259,6 @@ async def play(c: Client, m: Message): chat_id, AudioPiped( ytlink, - HighQualityAudio(), ), stream_type=StreamType().local_stream, ) From 9744529b804a9ef1f407bcbbe85808a691d97ef7 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 31 Jan 2022 18:37:46 +0700 Subject: [PATCH 48/48] add audio quality --- program/music.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/program/music.py b/program/music.py index 08b9c9f..354ea67 100644 --- a/program/music.py +++ b/program/music.py @@ -200,6 +200,7 @@ async def play(c: Client, m: Message): chat_id, AudioPiped( ytlink, + HighQualityAudio(), ), stream_type=StreamType().local_stream, ) @@ -259,6 +260,7 @@ async def play(c: Client, m: Message): chat_id, AudioPiped( ytlink, + HighQualityAudio(), ), stream_type=StreamType().local_stream, )