Compare commits
No commits in common. "06d97cbff0594729d68e1916270fd30b26bce941" and "361e86c384067b3ca50ac80c3b9d3e5cfde3679f" have entirely different histories.
06d97cbff0
...
361e86c384
1 changed files with 40 additions and 64 deletions
102
games/nude.py
102
games/nude.py
|
|
@ -3,7 +3,7 @@ from aiogram import types
|
||||||
import config
|
import config
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import re
|
import json
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -19,90 +19,66 @@ async def handle_nude_cmd(message: types.Message):
|
||||||
help_msg = (
|
help_msg = (
|
||||||
"🔥 <b>Справка по команде /nude:</b>\n\n"
|
"🔥 <b>Справка по команде /nude:</b>\n\n"
|
||||||
"Получает случайные изображения взрослых женщин из открытых источников.\n"
|
"Получает случайные изображения взрослых женщин из открытых источников.\n"
|
||||||
"• Использует прямое сканирование сайтов для поиска контента\n"
|
"• Использует Pornhub API для поиска контента\n"
|
||||||
"• По умолчанию ищет популярные изображения\n"
|
"• По умолчанию ищет популярные видео с высоким рейтингом\n"
|
||||||
"• Отправляет изображения напрямую\n\n"
|
"• Отправляет превью видео как изображение\n\n"
|
||||||
"<i>Пример:</i> <code>/nude</code>\n"
|
"<i>Пример:</i> <code>/nude</code>\n"
|
||||||
"<i>По умолчанию:</i> Случайные изображения с популярных сайтов"
|
"<i>По умолчанию:</i> Популярный контент для взрослых"
|
||||||
)
|
)
|
||||||
await message.reply(help_msg, parse_mode="HTML")
|
await message.reply(help_msg, parse_mode="HTML")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Список сайтов для сканирования
|
# Используем Pornhub API для поиска видео
|
||||||
sites = [
|
url = "https://www.pornhub.com/webmasters/search"
|
||||||
"https://www.imagefap.com/gallery.php?pg=random",
|
|
||||||
"https://xhamster.com/photos?sort=random",
|
|
||||||
"https://spankbang.com/random"
|
|
||||||
]
|
|
||||||
|
|
||||||
random_site = random.choice(sites)
|
params = {
|
||||||
|
"category": "straight",
|
||||||
|
"ordering": "mostviewed",
|
||||||
|
"period": "week",
|
||||||
|
"thumbsize": "medium"
|
||||||
|
}
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
|
||||||
"Accept-Language": "en-US,en;q=0.5",
|
|
||||||
"Accept-Encoding": "gzip, deflate",
|
|
||||||
"Connection": "keep-alive",
|
|
||||||
"Upgrade-Insecure-Requests": "1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(random_site, headers=headers) as resp:
|
async with session.get(url, params=params, headers=headers) as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
logger.error(f"Site access error: {resp.status}")
|
logger.error(f"Pornhub API Error: {resp.status}")
|
||||||
await message.reply("Не удалось получить доступ к сайту :(")
|
await message.reply("Не удалось получить контент от сервера :(")
|
||||||
return
|
return
|
||||||
|
|
||||||
html = await resp.text()
|
# Pornhub API возвращает HTML, нужно парсить
|
||||||
|
text = await resp.text()
|
||||||
|
|
||||||
# Ищем URL изображений в HTML
|
# Ищем URL превью в HTML
|
||||||
img_patterns = [
|
import re
|
||||||
r'<img[^>]+src="([^"]+)"',
|
thumb_pattern = r'<img[^>]+src="([^"]+)"[^>]+class="thumb"'
|
||||||
r'<a[^>]+href="([^"]+\.(jpg|jpeg|png|gif|webp))"',
|
matches = re.findall(thumb_pattern, text)
|
||||||
r'data-src="([^"]+)"'
|
|
||||||
]
|
|
||||||
|
|
||||||
img_urls = []
|
if not matches:
|
||||||
for pattern in img_patterns:
|
await message.reply("Не удалось найти контент :(")
|
||||||
matches = re.findall(pattern, html, re.IGNORECASE)
|
|
||||||
img_urls.extend(matches)
|
|
||||||
|
|
||||||
if not img_urls:
|
|
||||||
await message.reply("Изображения не найдены на странице :(")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Фильтруем и выбираем случайное изображение
|
# Берем случайное превью
|
||||||
valid_imgs = []
|
thumb_url = random.choice(matches)
|
||||||
for img_url in img_urls:
|
|
||||||
if img_url.startswith('//'):
|
|
||||||
img_url = 'https:' + img_url
|
|
||||||
elif img_url.startswith('/'):
|
|
||||||
if 'imagefap.com' in random_site:
|
|
||||||
img_url = 'https://www.imagefap.com' + img_url
|
|
||||||
elif 'xhamster.com' in random_site:
|
|
||||||
img_url = 'https://xhamster.com' + img_url
|
|
||||||
elif 'spankbang.com' in random_site:
|
|
||||||
img_url = 'https://spankbang.com' + img_url
|
|
||||||
|
|
||||||
if any(ext in img_url.lower() for ext in ['.jpg', '.jpeg', '.png', '.gif', '.webp']):
|
# Убедимся что URL полный
|
||||||
valid_imgs.append(img_url)
|
if not thumb_url.startswith('http'):
|
||||||
|
thumb_url = f"https://thumb.pornhub.com{thumb_url}"
|
||||||
|
|
||||||
if not valid_imgs:
|
caption = random.choice(CAPTIONS)
|
||||||
await message.reply("Подходящие изображения не найдены :(")
|
|
||||||
return
|
|
||||||
|
|
||||||
final_img_url = random.choice(valid_imgs)
|
# Отправляем как фото
|
||||||
caption = random.choice(CAPTIONS)
|
try:
|
||||||
|
input_file = types.URLInputFile(thumb_url)
|
||||||
# Отправляем изображение
|
await message.answer_photo(photo=input_file, caption=caption)
|
||||||
try:
|
except Exception as e:
|
||||||
input_file = types.URLInputFile(final_img_url)
|
logger.error(f"Error sending photo: {e}")
|
||||||
await message.answer_photo(photo=input_file, caption=caption)
|
await message.answer(f"{caption}\n{thumb_url}")
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error sending photo: {e}")
|
|
||||||
await message.answer(f"{caption}\n{final_img_url}")
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("Error in nude command")
|
logger.exception("Error in nude command")
|
||||||
await message.reply("Произошла ошибка при обработке запроса :(")
|
await message.reply("Произошла ошибка при обращении к API :(")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue