add abstraction ob platform and article + vinted
" Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -13,6 +13,7 @@ from datetime import datetime
|
||||
|
||||
ITEM_HTML = """
|
||||
<b>Artículo:</b> {title}
|
||||
<b>Plataforma:</b> {platform}
|
||||
|
||||
{description}
|
||||
|
||||
@@ -73,6 +74,7 @@ class TelegramManager:
|
||||
message = ITEM_HTML.format(
|
||||
search_name=self.escape_html(search_name),
|
||||
title=self.escape_html(article.get_title()),
|
||||
platform=self.escape_html(article.get_platform()),
|
||||
description=self.escape_html(article.get_description()),
|
||||
location=self.escape_html(article.get_location()),
|
||||
price=self.escape_html(article.get_price()),
|
||||
@@ -91,16 +93,16 @@ class TelegramManager:
|
||||
keyboard = [
|
||||
[
|
||||
InlineKeyboardButton("⭐ Añadir a favoritos", callback_data=f"fav_{article.get_id()}_{search_name}"),
|
||||
InlineKeyboardButton("Ir al anuncio", url=f"https://es.wallapop.com/item/{article.get_url()}")
|
||||
InlineKeyboardButton("Ir al anuncio", url=f"{article.get_url()}")
|
||||
]
|
||||
]
|
||||
reply_markup = InlineKeyboardMarkup(keyboard)
|
||||
|
||||
# Enviar un mensaje adicional con los botones (reply al primer mensaje del grupo)
|
||||
await self._bot.send_message(
|
||||
await self._bot.send_photo(
|
||||
chat_id=self._channel,
|
||||
photo=first_image_url,
|
||||
text=message,
|
||||
caption=message,
|
||||
parse_mode="HTML",
|
||||
reply_markup=reply_markup,
|
||||
message_thread_id=thread_id
|
||||
@@ -174,8 +176,8 @@ class TelegramManager:
|
||||
article_id = parts[1]
|
||||
search_name = parts[2]
|
||||
|
||||
# Obtener el mensaje original (el que tiene reply)
|
||||
original_message = query.message.reply_to_message
|
||||
# Ahora el mensaje original es el mismo mensaje del keyboard
|
||||
original_message = query.message
|
||||
|
||||
if not original_message:
|
||||
await query.edit_message_text("❌ No se pudo encontrar el mensaje original")
|
||||
@@ -198,7 +200,7 @@ class TelegramManager:
|
||||
|
||||
# Verificar si ya existe
|
||||
if any(fav["id"] == article_id for fav in favorites):
|
||||
await query.edit_message_text("ℹ️ Este artículo ya está en favoritos")
|
||||
await query.message.reply_text("ℹ️ Este artículo ya está en favoritos")
|
||||
return
|
||||
|
||||
# Añadir nuevo favorito
|
||||
@@ -211,7 +213,6 @@ class TelegramManager:
|
||||
[InlineKeyboardButton("🗑️ Quitar de favoritos", callback_data=f"unfav_{article_id}")]
|
||||
]
|
||||
await query.edit_message_text(
|
||||
text="💾 Acciones:",
|
||||
reply_markup=InlineKeyboardMarkup(new_keyboard)
|
||||
)
|
||||
|
||||
@@ -283,7 +284,7 @@ class TelegramManager:
|
||||
[InlineKeyboardButton("⭐ Añadir a favoritos", callback_data=f"fav_{article_id}_unknown")]
|
||||
]
|
||||
await query.edit_message_text(
|
||||
text="💾 Acciones:",
|
||||
text="💾 Acciones",
|
||||
reply_markup=InlineKeyboardMarkup(keyboard)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user