aboutsummaryrefslogtreecommitdiff
path: root/handlers/gif.py
diff options
context:
space:
mode:
Diffstat (limited to 'handlers/gif.py')
-rw-r--r--handlers/gif.py41
1 files changed, 41 insertions, 0 deletions
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 @@
1from os import system as run
2
3from aiogram import types as t
4from aiogram.dispatcher import filters
5
6from handlers.gen import получить_говно
7from shared.instances import dp
8
9
10@dp.message_handler(
11 filters.Command("gif", ignore_caption=False),
12 content_types=[t.ContentType.PHOTO, t.ContentType.DOCUMENT, t.ContentType.TEXT],
13 commands=["gif"]
14)
15async def высрать_гиф(msg: t.Message):
16 tmp = "tmp/"
17 inp = tmp + "gif.jpg"
18 out = tmp + "gif.mp4"
19
20 try:
21 if msg.text:
22 photo = msg.reply_to_message.photo
23 document = msg.reply_to_message.document
24 else:
25 photo = msg.photo
26 document = msg.document
27
28 if photo:
29 await photo[-1].download(destination_file=inp)
30 elif document:
31 await document.download(destination_file=inp)
32 else:
33 raise RuntimeError()
34 except Exception:
35 await msg.reply("Чел, ответь на фото или пришли мне его")
36 return
37
38 run(f"ffmpeg -loglevel quiet -y -i {inp} {out}")
39
40 with open(out, "rb") as file:
41 await msg.reply_animation(file, caption=получить_говно())