bot_tg/games/nude.py
2026-04-10 10:47:56 +03:00

84 lines
3.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import aiohttp
from aiogram import types
import config
import logging
import random
import json
logger = logging.getLogger(__name__)
CAPTIONS = [
"Hot stuff 🔥",
"Sexy content 😏"
]
async def handle_nude_cmd(message: types.Message):
args = message.text.split(maxsplit=1)
if len(args) > 1 and args[1].strip() == "-h":
help_msg = (
"🔥 <b>Справка по команде /nude:</b>\n\n"
"Получает случайные изображения взрослых женщин из открытых источников.\n"
"• Использует Pornhub API для поиска контента\n"
"• По умолчанию ищет популярные видео с высоким рейтингом\n"
"• Отправляет превью видео как изображение\n\n"
"<i>Пример:</i> <code>/nude</code>\n"
"<i>По умолчанию:</i> Популярный контент для взрослых"
)
await message.reply(help_msg, parse_mode="HTML")
return
# Используем Pornhub API для поиска видео
url = "https://www.pornhub.com/webmasters/search"
params = {
"category": "straight",
"ordering": "mostviewed",
"period": "week",
"thumbsize": "medium"
}
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
}
try:
async with aiohttp.ClientSession() as session:
async with session.get(url, params=params, headers=headers) as resp:
if resp.status != 200:
logger.error(f"Pornhub API Error: {resp.status}")
await message.reply("Не удалось получить контент от сервера :(")
return
# Pornhub API возвращает HTML, нужно парсить
text = await resp.text()
# Ищем URL превью в HTML
import re
thumb_pattern = r'<img[^>]+src="([^"]+)"[^>]+class="thumb"'
matches = re.findall(thumb_pattern, text)
if not matches:
await message.reply("Не удалось найти контент :(")
return
# Берем случайное превью
thumb_url = random.choice(matches)
# Убедимся что URL полный
if not thumb_url.startswith('http'):
thumb_url = f"https://thumb.pornhub.com{thumb_url}"
caption = random.choice(CAPTIONS)
# Отправляем как фото
try:
input_file = types.URLInputFile(thumb_url)
await message.answer_photo(photo=input_file, caption=caption)
except Exception as e:
logger.error(f"Error sending photo: {e}")
await message.answer(f"{caption}\n{thumb_url}")
except Exception as e:
logger.exception("Error in nude command")
await message.reply("Произошла ошибка при обращении к API :(")