1
0
Fork 0
forked from zovos/bot_tg

Merge pull request 'feat: add more random captions for /uwu' (#17) from Furrex/bot_tg:main into main

Reviewed-on: zovos/bot_tg#17
This commit is contained in:
q 2026-03-23 10:12:40 +00:00
commit 29cd511186

View file

@ -2,9 +2,15 @@ import aiohttp
from aiogram import types
import config
import logging
import random
logger = logging.getLogger(__name__)
CAPTIONS = [
"Ня :3",
"uwu"
]
async def handle_uwu_cmd(message: types.Message):
args = message.text.split(maxsplit=1)
@ -16,12 +22,12 @@ async def handle_uwu_cmd(message: types.Message):
"• <b>score</b>: <code>score:>500</code> (искать популярные посты с рейтингом больше 500)\n"
"• Исключить тег: поставьте минус, например <code>-fox</code>\n\n"
"<i>Пример:</i> <code>/uwu wolf -rating:explicit score:>100</code>\n"
"<i>По умолчанию:</i> <code>rating:safe score:>500</code>"
"<i>По умолчанию:</i> <code>rating:safe score:>500 -animated</code>"
)
await message.reply(help_msg, parse_mode="HTML")
return
tags = "rating:safe score:>500"
tags = "rating:safe score:>500 -animated"
if len(args) > 1:
tags = args[1].strip()
@ -57,11 +63,21 @@ async def handle_uwu_cmd(message: types.Message):
post = posts[0]
file_url = post.get("file", {}).get("url")
ext = post.get("file", {}).get("ext", "png")
if not file_url:
await message.reply("У найденного поста нет прямого URL изображения :(")
return
await message.answer_photo(photo=types.URLInputFile(file_url), caption="Ня :3")
input_file = types.URLInputFile(file_url)
caption = random.choice(CAPTIONS)
if ext in ("png", "jpg", "jpeg", "webp"):
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:
await message.answer_document(document=input_file, caption=caption)
except Exception as e:
logger.exception("Error in uwu command")