Compare commits
No commits in common. "29cd511186ca93429c108ee65a527705fd3e73f9" and "801d6da69bc3d30484fa98cbadc1afd082d655f4" have entirely different histories.
29cd511186
...
801d6da69b
1 changed files with 3 additions and 19 deletions
22
games/uwu.py
22
games/uwu.py
|
|
@ -2,15 +2,9 @@ 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)
|
||||
|
||||
|
|
@ -22,12 +16,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 -animated</code>"
|
||||
"<i>По умолчанию:</i> <code>rating:safe score:>500</code>"
|
||||
)
|
||||
await message.reply(help_msg, parse_mode="HTML")
|
||||
return
|
||||
|
||||
tags = "rating:safe score:>500 -animated"
|
||||
tags = "rating:safe score:>500"
|
||||
if len(args) > 1:
|
||||
tags = args[1].strip()
|
||||
|
||||
|
|
@ -63,21 +57,11 @@ 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
|
||||
|
||||
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)
|
||||
await message.answer_photo(photo=types.URLInputFile(file_url), caption="Ня :3")
|
||||
|
||||
except Exception as e:
|
||||
logger.exception("Error in uwu command")
|
||||
|
|
|
|||
Loading…
Reference in a new issue