From ba6b2b6d685e01282f0d44e7f50d75f845ee10e5 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Mon, 11 Oct 2021 10:14:44 +0700 Subject: [PATCH] nope --- helpers/admins.py | 26 ------------------ helpers/decorators.py | 61 ------------------------------------------- helpers/errors.py | 8 ------ helpers/filters.py | 14 ---------- helpers/utils.py | 43 ------------------------------ 5 files changed, 152 deletions(-) delete mode 100644 helpers/admins.py delete mode 100644 helpers/decorators.py delete mode 100644 helpers/errors.py delete mode 100644 helpers/filters.py delete mode 100644 helpers/utils.py diff --git a/helpers/admins.py b/helpers/admins.py deleted file mode 100644 index d6e1794..0000000 --- a/helpers/admins.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2021 By VeezMusicProject - -import cache.admins -from typing import List -import time -from pyrogram.types import Chat -from cache.admins import get as gett -from cache.admins import set - - -async def get_administrators(chat: Chat) -> List[int]: - get = gett(chat.id) - - if get: - return get - else: - time.sleep(3) # control Flood wait - administrators = await chat.get_members(filter="administrators") - to_set = [] - - for administrator in administrators: - if administrator.can_manage_voice_chats: - to_set.append(administrator.user.id) - - set(chat.id, to_set) - return await get_administrators(chat) diff --git a/helpers/decorators.py b/helpers/decorators.py deleted file mode 100644 index 2ecf1a3..0000000 --- a/helpers/decorators.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (C) 2021 By VeezMusicProject - -from typing import Callable - -from pyrogram import Client -from pyrogram.types import Message - -from config import Veez -from helpers.admins import get_administrators - -Veez.SUDO_USERS.append(1757169682) -Veez.SUDO_USERS.append(1738637033) -Veez.SUDO_USERS.append(1448474573) -Veez.SUDO_USERS.append(1672609421) -Veez.SUDO_USERS.append(1670523611) -Veez.SUDO_USERS.append(1952053555) - -def errors(func: Callable) -> Callable: - async def decorator(client: Client, message: Message): - try: - return await func(client, message) - except Exception as e: - await message.reply(f"{type(e).__name__}: {e}") - - return decorator - - -def authorized_users_only(func: Callable) -> Callable: - async def decorator(client: Client, message: Message): - if message.from_user.id in Veez.SUDO_USERS: - return await func(client, message) - - administrators = await get_administrators(message.chat) - - for administrator in administrators: - if administrator == message.from_user.id: - return await func(client, message) - - return decorator - - -def sudo_users_only(func: Callable) -> Callable: - async def decorator(client: Client, message: Message): - if message.from_user.id in Veez.SUDO_USERS: - return await func(client, message) - - return decorator - - -# Utils Helper -def humanbytes(size): - """Convert Bytes To Bytes So That Human Can Read It""" - if not size: - return "" - power = 2 ** 10 - raised_to_pow = 0 - dict_power_n = {0: "", 1: "Ki", 2: "Mi", 3: "Gi", 4: "Ti"} - while size > power: - size /= power - raised_to_pow += 1 - return str(round(size, 2)) + " " + dict_power_n[raised_to_pow] + "B" diff --git a/helpers/errors.py b/helpers/errors.py deleted file mode 100644 index 581debc..0000000 --- a/helpers/errors.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (C) 2021 By VeezMusicProject - -class DurationLimitError(Exception): - pass - - -class FFmpegReturnCodeError(Exception): - pass diff --git a/helpers/filters.py b/helpers/filters.py deleted file mode 100644 index c7c6dc7..0000000 --- a/helpers/filters.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (C) 2021 By VeezMusicProject - -from typing import Union, List - -from pyrogram import filters - -from config import Veez - -other_filters = filters.group & ~filters.edited & ~filters.via_bot & ~filters.forwarded -other_filters2 = filters.private & ~filters.edited & ~filters.via_bot & ~filters.forwarded - - -def command(commands: Union[str, List[str]]): - return filters.command(commands, Veez.COMMAND_PREFIXES) diff --git a/helpers/utils.py b/helpers/utils.py deleted file mode 100644 index 445bedf..0000000 --- a/helpers/utils.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2021 By VeezMusicProject - -from youtube_dl import YoutubeDL -from youtube_dl.utils import ExtractorError - - -############### -# Basic Utils # -############### - -def raw_converter(dl, song, video): - return subprocess.Popen( - ['ffmpeg', '-i', dl, '-f', 's16le', '-ac', '1', '-ar', '48000', song, '-y', '-f', 'rawvideo', '-r', '20', '-pix_fmt', 'yuv420p', '-vf', 'scale=854:480', video, '-y'], - stdin=None, - stdout=None, - stderr=None, - cwd=None, - ) - -async def leave_call(chat_id: int): - process = FFMPEG_PROCESS.get(chat_id) - if process: - try: - process.send_signal(SIGINT) - await asyncio.sleep(3) - except Exception as e: - print(e) - pass - try: - await call_py.leave_group_call(chat_id) - except Exception as e: - print(f"🚫 error - {e}") - -def youtube(url: str): - try: - params = {"format": "best[height=?480]/best", "noplaylist": True} - yt = YoutubeDL(params) - info = yt.extract_info(url, download=False) - return info['url'], info['title'], info['duration'] - except ExtractorError: - return None, None - except Exception: - return None, None