From 1f8b8b67b81c5ae86980d9129f3a88db61165698 Mon Sep 17 00:00:00 2001 From: Igor <50257429+igorechek06@users.noreply.github.com> Date: Fri, 15 Oct 2021 14:07:38 +0900 Subject: Фотки в gif для абьюз телеграм MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handlers/gif.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 handlers/gif.py (limited to 'handlers/gif.py') diff --git a/handlers/gif.py b/handlers/gif.py new file mode 100644 index 0000000..3961502 --- /dev/null +++ b/handlers/gif.py @@ -0,0 +1,41 @@ +from os import system as run + +from aiogram import types as t +from aiogram.dispatcher import filters + +from handlers.gen import получить_говно +from shared.instances import dp + + +@dp.message_handler( + filters.Command("gif", ignore_caption=False), + content_types=[t.ContentType.PHOTO, t.ContentType.DOCUMENT, t.ContentType.TEXT], + commands=["gif"] +) +async def высрать_гиф(msg: t.Message): + tmp = "tmp/" + inp = tmp + "gif.jpg" + out = tmp + "gif.mp4" + + try: + if msg.text: + photo = msg.reply_to_message.photo + document = msg.reply_to_message.document + else: + photo = msg.photo + document = msg.document + + if photo: + await photo[-1].download(destination_file=inp) + elif document: + await document.download(destination_file=inp) + else: + raise RuntimeError() + except Exception: + await msg.reply("Чел, ответь на фото или пришли мне его") + return + + run(f"ffmpeg -loglevel quiet -y -i {inp} {out}") + + with open(out, "rb") as file: + await msg.reply_animation(file, caption=получить_говно()) -- cgit v1.2.3