Спойлер для /uwu и /nude #28
3 changed files with 9 additions and 5 deletions
1
.env
1
.env
|
|
@ -4,3 +4,4 @@ ODDS_API_KEY=c29bc26dee8aa9d95a5ce8d14ea63923
|
||||||
LLAMA_API_URL=https://mirror.porno4free.ru/zovos-ai/
|
LLAMA_API_URL=https://mirror.porno4free.ru/zovos-ai/
|
||||||
LLAMA_FORCE_DISABLE_THINKING=0
|
LLAMA_FORCE_DISABLE_THINKING=0
|
||||||
LLAMA_LOG_THINKING=1
|
LLAMA_LOG_THINKING=1
|
||||||
|
WEBAPP_URL=https://uninterleaved-scrawnily-nicol.ngrok-free.dev
|
||||||
|
|
|
||||||
|
|
@ -302,12 +302,12 @@ async def handle_nude_cmd(message: types.Message):
|
||||||
|
|
||||||
if image_bytes:
|
if image_bytes:
|
||||||
photo = types.BufferedInputFile(image_bytes, filename=filename)
|
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
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
photo = types.URLInputFile(selected["image_url"])
|
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:
|
except Exception:
|
||||||
logger.exception("Failed to send photo by URL")
|
logger.exception("Failed to send photo by URL")
|
||||||
await message.answer(
|
await message.answer(
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ async def fetch_uwu_post(tags: str) -> dict:
|
||||||
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")
|
ext = post.get("file", {}).get("ext", "png")
|
||||||
|
rating = post.get("rating", "s") # s=safe, q=questionable, e=explicit
|
||||||
if not file_url:
|
if not file_url:
|
||||||
raise Exception("У найденного поста нет прямого URL изображения :(")
|
raise Exception("У найденного поста нет прямого URL изображения :(")
|
||||||
|
|
||||||
|
|
@ -91,7 +92,8 @@ async def fetch_uwu_post(tags: str) -> dict:
|
||||||
return {
|
return {
|
||||||
"url": file_url,
|
"url": file_url,
|
||||||
"ext": ext,
|
"ext": ext,
|
||||||
"caption": caption
|
"caption": caption,
|
||||||
|
"rating": rating
|
||||||
}
|
}
|
||||||
|
|
||||||
async def fetch_furtok_feed(safe: bool = True, page: int = 1, extra_tags: str = "") -> list[dict]:
|
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"]
|
file_url = post["url"]
|
||||||
ext = post["ext"]
|
ext = post["ext"]
|
||||||
caption = post["caption"]
|
caption = post["caption"]
|
||||||
|
spoiler = post.get("rating") == "e" # спойлер для explicit
|
||||||
|
|
||||||
if ext in ("gif", "webm", "mp4"):
|
if ext in ("gif", "webm", "mp4"):
|
||||||
# Для анимаций: отправляем caption отдельным сообщением,
|
# Для анимаций: отправляем caption отдельным сообщением,
|
||||||
# а саму гифку/видео через URL напрямую — так Telegram
|
# а саму гифку/видео через URL напрямую — так Telegram
|
||||||
# корректно показывает её как анимацию, а не как файл
|
# корректно показывает её как анимацию, а не как файл
|
||||||
await message.answer(caption)
|
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"):
|
elif ext in ("png", "jpg", "jpeg", "webp"):
|
||||||
input_file = types.URLInputFile(file_url)
|
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:
|
else:
|
||||||
input_file = types.URLInputFile(file_url)
|
input_file = types.URLInputFile(file_url)
|
||||||
await message.answer_document(document=input_file, caption=caption)
|
await message.answer_document(document=input_file, caption=caption)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue