forked from zovos/bot_tg
fix: uwu gifs now sent as animation, caption as separate message
This commit is contained in:
parent
3baf71ab98
commit
f0cefc7f23
1 changed files with 9 additions and 6 deletions
15
games/uwu.py
15
games/uwu.py
|
|
@ -68,15 +68,18 @@ async def handle_uwu_cmd(message: types.Message):
|
||||||
await message.reply("У найденного поста нет прямого URL изображения :(")
|
await message.reply("У найденного поста нет прямого URL изображения :(")
|
||||||
return
|
return
|
||||||
|
|
||||||
input_file = types.URLInputFile(file_url)
|
|
||||||
caption = random.choice(CAPTIONS)
|
caption = random.choice(CAPTIONS)
|
||||||
if ext in ("png", "jpg", "jpeg", "webp"):
|
if ext in ("gif", "webm", "mp4"):
|
||||||
|
# Для анимаций: отправляем caption отдельным сообщением,
|
||||||
|
# а саму гифку/видео через URL напрямую — так Telegram
|
||||||
|
# корректно показывает её как анимацию, а не как файл
|
||||||
|
await message.answer(caption)
|
||||||
|
await message.answer_animation(animation=file_url)
|
||||||
|
elif ext in ("png", "jpg", "jpeg", "webp"):
|
||||||
|
input_file = types.URLInputFile(file_url)
|
||||||
await message.answer_photo(photo=input_file, caption=caption)
|
await message.answer_photo(photo=input_file, caption=caption)
|
||||||
elif ext == "gif":
|
|
||||||
await message.answer_animation(animation=input_file, caption=caption)
|
|
||||||
elif ext in ("webm", "mp4"):
|
|
||||||
await message.answer_video(video=input_file, caption=caption)
|
|
||||||
else:
|
else:
|
||||||
|
input_file = types.URLInputFile(file_url)
|
||||||
await message.answer_document(document=input_file, caption=caption)
|
await message.answer_document(document=input_file, caption=caption)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue