From 6e6ee8ff406d4107c4be75869418e2aacb46d066 Mon Sep 17 00:00:00 2001 From: King-of-the-all-Cookies Date: Fri, 1 May 2026 17:48:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BF=D1=80=D0=BE=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=87?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20=D0=B4=D0=B5?= =?UTF-8?q?=D1=82=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D0=BC=D0=BE=D1=82=D1=80=D0=B0:=20=D1=83=D0=B4?= =?UTF-8?q?=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B8=20=D1=83?= =?UTF-8?q?=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D1=82=D0=BE=D0=B2=D1=8B=D1=85=20=D1=81=D0=BE=D0=BE?= =?UTF-8?q?=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- detailed_handlers.py | 94 ++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 60 deletions(-) diff --git a/detailed_handlers.py b/detailed_handlers.py index eb834e7..907b12f 100644 --- a/detailed_handlers.py +++ b/detailed_handlers.py @@ -1,10 +1,9 @@ """ -Inline handlers for detailed item viewing with images (FIXED VERSION) +Inline handlers for detailed item viewing (NO IMAGES VERSION - STABLE) """ from telegram import Update from telegram.ext import ContextTypes, CommandHandler from vndb_client import VndbClient -from utils import ImageHandler from config import Config import logging @@ -21,29 +20,31 @@ class DetailedHandlers: async def view_vn_detail(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: try: if not context.args: - await update.message.reply_text( - "❌ Укажи ID VN\nПример: /vn_detail v2002" - ) + await update.message.reply_text("❌ Пример: /vn_detail v2002") return vn_id = context.args[0].strip() - await update.message.reply_text( - f"⏳ Загружаю информацию о {vn_id}..." - ) + await update.message.reply_text(f"⏳ Загружаю {vn_id}...") results = await vndb_client.query_vn( filters=["id", "=", vn_id], fields=[ - "id", "title", "original", "released", - "rating", "votecount", "description", - "length", "developer", "image{url,dims}" + "id", + "title", + "original", + "released", + "rating", + "votecount", + "description", + "length", + "developer" ], results=1 ) if not results.get("results"): - await update.message.reply_text(f"😞 VN {vn_id} не найдена") + await update.message.reply_text("😞 VN не найдена") return vn = results["results"][0] @@ -51,27 +52,22 @@ class DetailedHandlers: text = f"🎮 {vn.get('title','Unknown')} (`{vn_id}`)\n" if vn.get("original"): - text += f"Оригинал: {vn['original']}\n" + text += f"{vn['original']}\n" text += f"Релиз: {vn.get('released','?')}\n" text += f"Рейтинг: {vn.get('rating',0)/10:.1f} ({vn.get('votecount',0)} голосов)\n" + if vn.get("length"): + text += f"Длина: {vn['length']}\n" + if vn.get("developer"): text += f"Разработчик: {vn['developer']}\n" if vn.get("description"): - desc = vn["description"][:300] - text += f"\nОписание:\n{desc}...\n" + text += f"\nОписание:\n{vn['description'][:300]}...\n" text += f"\nhttps://vndb.org/{vn_id}" - img = vn.get("image") - if img: - url = ImageHandler.get_image_url(img) - if url: - await update.message.reply_photo(photo=url, caption=text) - return - await update.message.reply_text(text) except Exception as e: @@ -96,10 +92,12 @@ class DetailedHandlers: results = await vndb_client.query_character( filters=["id", "=", char_id], fields=[ - "id", "name", "original", - "gender", "bloodtype", - "description", "image{url,dims}", - "vn" + "id", + "name", + "original", + "gender", + "bloodtype", + "description" ], results=1 ) @@ -121,24 +119,11 @@ class DetailedHandlers: if c.get("bloodtype"): text += f"Кровь: {c['bloodtype']}\n" - if c.get("vn"): - text += "\nVN:\n" - for vn in c["vn"][:5]: - if vn.get("id"): - text += f"• {vn['id']}\n" - if c.get("description"): - text += f"\n{c['description'][:300]}...\n" + text += f"\nОписание:\n{c['description'][:300]}...\n" text += f"\nhttps://vndb.org/{char_id}" - img = c.get("image") - if img: - url = ImageHandler.get_image_url(img) - if url: - await update.message.reply_photo(photo=url, caption=text) - return - await update.message.reply_text(text) except Exception as e: @@ -163,12 +148,14 @@ class DetailedHandlers: results = await vndb_client.query_release( filters=["id", "=", release_id], fields=[ - "id", "title", "original", - "released", "platform", - "type", "language", - "description", - "image{url,dims}", - "vn" + "id", + "title", + "original", + "released", + "platform", + "type", + "language", + "description" ], results=1 ) @@ -191,24 +178,11 @@ class DetailedHandlers: if r.get("language"): text += f"Языки: {', '.join(r['language'])}\n" - if r.get("vn"): - text += "\nVN:\n" - for vn in r["vn"][:3]: - if vn.get("id"): - text += f"• {vn['id']}\n" - if r.get("description"): - text += f"\n{r['description'][:200]}...\n" + text += f"\nОписание:\n{r['description'][:200]}...\n" text += f"\nhttps://vndb.org/{release_id}" - img = r.get("image") - if img: - url = ImageHandler.get_image_url(img) - if url: - await update.message.reply_photo(photo=url, caption=text) - return - await update.message.reply_text(text) except Exception as e: