blob: caf025ca54e47722ec51ee7fc313dc9f020da0e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
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],
)
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"
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}")
|