diff options
Diffstat (limited to 'handlers/gif.py')
| -rw-r--r-- | handlers/gif.py | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/handlers/gif.py b/handlers/gif.py deleted file mode 100644 index 5b3d5bc..0000000 --- a/handlers/gif.py +++ /dev/null | |||
| @@ -1,57 +0,0 @@ | |||
| 1 | from os import system as run | ||
| 2 | |||
| 3 | from aiogram import types as t | ||
| 4 | from aiogram.dispatcher import filters | ||
| 5 | |||
| 6 | from shared.instances import dp | ||
| 7 | |||
| 8 | |||
| 9 | @dp.message_handler( | ||
| 10 | filters.Command("gif", ignore_caption=False), | ||
| 11 | content_types=[t.ContentType.PHOTO, t.ContentType.DOCUMENT], | ||
| 12 | ) | ||
| 13 | async def высрать_гифку_по_фото(msg: t.Message): | ||
| 14 | from handlers.gen import получить_говно | ||
| 15 | |||
| 16 | if await скачать_и_обработать_файл(msg): | ||
| 17 | with open("tmp/gif.mp4", "rb") as file: | ||
| 18 | await msg.reply_animation(file, caption=получить_говно()) | ||
| 19 | |||
| 20 | |||
| 21 | @dp.message_handler( | ||
| 22 | commands=["gif"], | ||
| 23 | content_types=[t.ContentType.TEXT], | ||
| 24 | ) | ||
| 25 | async def высрать_гифку_по_ответу(msg: t.Message): | ||
| 26 | from handlers.gen import получить_говно | ||
| 27 | |||
| 28 | if await скачать_и_обработать_файл(msg): | ||
| 29 | with open("tmp/gif.mp4", "rb") as file: | ||
| 30 | await msg.reply_animation(file, caption=получить_говно()) | ||
| 31 | |||
| 32 | |||
| 33 | async def скачать_и_обработать_файл(msg: t.Message): | ||
| 34 | tmp = "tmp/" | ||
| 35 | inp = tmp + "gif.jpg" | ||
| 36 | out = tmp + "gif.mp4" | ||
| 37 | |||
| 38 | try: | ||
| 39 | if msg.text: | ||
| 40 | photo = msg.reply_to_message.photo | ||
| 41 | document = msg.reply_to_message.document | ||
| 42 | else: | ||
| 43 | photo = msg.photo | ||
| 44 | document = msg.document | ||
| 45 | |||
| 46 | if photo: | ||
| 47 | await photo[-1].download(destination_file=inp) | ||
| 48 | elif document: | ||
| 49 | await document.download(destination_file=inp) | ||
| 50 | else: | ||
| 51 | raise RuntimeError() | ||
| 52 | except Exception: | ||
| 53 | await msg.reply("Чел, ответь на фото или пришли мне его") | ||
| 54 | return False | ||
| 55 | |||
| 56 | run(f"ffmpeg -loglevel quiet -y -i {inp} {out}") | ||
| 57 | return True | ||
