From 90dfead5a4ec16b8da11a0c05975025ef0c252e1 Mon Sep 17 00:00:00 2001 From: Abhi <85984486+AbhiTheModder@users.noreply.github.com> Date: Sat, 6 Jan 2024 02:31:43 +0000 Subject: [PATCH] Fixes --- Dockerfile | 1 + utils/scripts.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 541d9d5..94df58f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM python:3.11 WORKDIR /app COPY . /app +RUN apt -qq update && apt -qq install -y git wget ffmpeg mediainfo RUN pip install -r requirements.txt CMD ["python", "main.py"] \ No newline at end of file diff --git a/utils/scripts.py b/utils/scripts.py index 06f543e..1ed2b5c 100644 --- a/utils/scripts.py +++ b/utils/scripts.py @@ -26,7 +26,8 @@ import importlib import subprocess from io import BytesIO from types import ModuleType -from typing import Dict +from typing import Dict, Tuple +import shlex from PIL import Image from pyrogram.errors import FloodWait, MessageNotModified @@ -139,6 +140,54 @@ async def progress(current, total, message, start, type_of_ps, file_name=None): except MessageNotModified: pass +async def run_cmd(prefix: str) -> Tuple[str, str, int, int]: + """Run Commands""" + args = shlex.split(prefix) + process = await asyncio.create_subprocess_exec( + *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE + ) + stdout, stderr = await process.communicate() + return ( + stdout.decode("utf-8", "replace").strip(), + stderr.decode("utf-8", "replace").strip(), + process.returncode, + process.pid, + ) + +def mediainfo(media): + xx = str((str(media)).split("(", maxsplit=1)[0]) + m = "" + if xx == "MessageMediaDocument": + mim = media.document.mime_type + if mim == "application/x-tgsticker": + m = "sticker animated" + elif "image" in mim: + if mim == "image/webp": + m = "sticker" + elif mim == "image/gif": + m = "gif as doc" + else: + m = "pic as doc" + elif "video" in mim: + if "DocumentAttributeAnimated" in str(media): + m = "gif" + elif "DocumentAttributeVideo" in str(media): + i = str(media.document.attributes[0]) + if "supports_streaming=True" in i: + m = "video" + m = "video as doc" + else: + m = "video" + elif "audio" in mim: + m = "audio" + else: + m = "document" + elif xx == "MessageMediaPhoto": + m = "pic" + elif xx == "MessageMediaWebPage": + m = "web" + return m + async def edit_or_reply(message, text, parse_mode=enums.ParseMode.MARKDOWN): """Edit Message If Its From Self, Else Reply To Message""" if not message: