feat: spoiler for explicit content in /uwu and /nude

This commit is contained in:
Danil 2026-04-20 18:11:39 +03:00
parent 9216bde63a
commit 88ceb2ef29
3 changed files with 9 additions and 5 deletions

1
.env
View file

@ -4,3 +4,4 @@ ODDS_API_KEY=c29bc26dee8aa9d95a5ce8d14ea63923
LLAMA_API_URL=https://mirror.porno4free.ru/zovos-ai/
LLAMA_FORCE_DISABLE_THINKING=0
LLAMA_LOG_THINKING=1
WEBAPP_URL=https://uninterleaved-scrawnily-nicol.ngrok-free.dev

View file

@ -302,12 +302,12 @@ async def handle_nude_cmd(message: types.Message):
if image_bytes:
photo = types.BufferedInputFile(image_bytes, filename=filename)
await message.answer_photo(photo=photo, caption=caption)
await message.answer_photo(photo=photo, caption=caption, has_spoiler=True)
return
try:
photo = types.URLInputFile(selected["image_url"])
await message.answer_photo(photo=photo, caption=caption)
await message.answer_photo(photo=photo, caption=caption, has_spoiler=True)
except Exception:
logger.exception("Failed to send photo by URL")
await message.answer(

View file

@ -84,6 +84,7 @@ async def fetch_uwu_post(tags: str) -> dict:
post = posts[0]
file_url = post.get("file", {}).get("url")
ext = post.get("file", {}).get("ext", "png")
rating = post.get("rating", "s") # s=safe, q=questionable, e=explicit
if not file_url:
raise Exception("У найденного поста нет прямого URL изображения :(")
@ -91,7 +92,8 @@ async def fetch_uwu_post(tags: str) -> dict:
return {
"url": file_url,
"ext": ext,
"caption": caption
"caption": caption,
"rating": rating
}
async def fetch_furtok_feed(safe: bool = True, page: int = 1, extra_tags: str = "") -> list[dict]:
@ -178,16 +180,17 @@ async def handle_uwu_cmd(message: types.Message):
file_url = post["url"]
ext = post["ext"]
caption = post["caption"]
spoiler = post.get("rating") == "e" # спойлер для explicit
if ext in ("gif", "webm", "mp4"):
# Для анимаций: отправляем caption отдельным сообщением,
# а саму гифку/видео через URL напрямую — так Telegram
# корректно показывает её как анимацию, а не как файл
await message.answer(caption)
await message.answer_animation(animation=file_url)
await message.answer_animation(animation=file_url, has_spoiler=spoiler)
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, has_spoiler=spoiler)
else:
input_file = types.URLInputFile(file_url)
await message.answer_document(document=input_file, caption=caption)