From e0e5820e0cb734c4e574db4a1fb7c1bc66de1a3a Mon Sep 17 00:00:00 2001 From: Igor <50257429+igorechek06@users.noreply.github.com> Date: Fri, 15 Oct 2021 14:21:09 +0900 Subject: I hate filters --- handlers/gif.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'handlers') diff --git a/handlers/gif.py b/handlers/gif.py index 3961502..caf025c 100644 --- a/handlers/gif.py +++ b/handlers/gif.py @@ -9,10 +9,25 @@ 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"] + content_types=[t.ContentType.PHOTO, t.ContentType.DOCUMENT], ) -async def высрать_гиф(msg: t.Message): +async def высрать_гифку_по_фото(msg: t.Message): + await скачать_файл(msg) + with open("tmp/gif.mp4", "rb") as file: + await msg.reply_animation(file, caption=получить_говно()) + + +@dp.message_handler( + commands=["gif"], + content_types=[t.ContentType.TEXT], +) +async def высрать_гифку_по_ответу(msg: t.Message): + await скачать_файл(msg) + with open("tmp/gif.mp4", "rb") as file: + await msg.reply_animation(file, caption=получить_говно()) + + +async def скачать_файл(msg: t.Message): tmp = "tmp/" inp = tmp + "gif.jpg" out = tmp + "gif.mp4" @@ -36,6 +51,3 @@ async def высрать_гиф(msg: t.Message): 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