Compare commits

..

No commits in common. "29cd511186ca93429c108ee65a527705fd3e73f9" and "801d6da69bc3d30484fa98cbadc1afd082d655f4" have entirely different histories.

View file

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