Changed markdown to html

This commit is contained in:
Joan
2025-09-17 17:57:44 +02:00
parent 16776f8766
commit b02e327aaf
4 changed files with 66 additions and 75 deletions

View File

@@ -9,7 +9,7 @@ import os # Import os to get BOT_TOKEN
# Import necessary functions from your project structure
# Adjust the path if paypal_processor.py is not in the root 'app' directory
# Assuming it can access the other modules directly as in the docker setup:
from helpers import generate_table_image, format_last_participants_list, escape_markdown_v2_chars_for_username, get_paypal_access_token
from helpers import generate_table_image, format_last_participants_list, get_paypal_access_token
from database import (
get_user_by_invoice_id, confirm_reserved_numbers,
get_raffle_name, get_raffle,
@@ -222,18 +222,18 @@ def receive_paypal_payment(invoice_id, payment_status, payment_amount_str):
# If it's the last number, update the main message and delete the participate button
if remaining_numbers_amount == 0:
keyboard = None
main_announcement = f"🎯🏆🎯 **Sorteo '{raffle_name}' terminado** 🎯🏆🎯\n\n"
main_announcement = f"🎯🏆🎯 <b>Sorteo '{raffle_name}' terminado</b> 🎯🏆🎯\n\n"
main_announcement += f"{raffle_details['description']}\n\n"
main_announcement += f"🌍 Envío internacional: {'Sí ✅' if raffle_details['international_shipping'] else 'No ❌'}\n"
main_announcement += f"💵 **Donación mínima:** {raffle_details['price']}\n"
main_announcement += f"📜 Normas y condiciones: {TYC_DOCUMENT_URL}"
main_announcement += f"💵 <b>Donación mínima:</b> {raffle_details['price']}\n"
main_announcement += f"📜 <b>Normas y condiciones:</b> {TYC_DOCUMENT_URL}"
main_message_id = get_main_message_id(raffle_id)
requests.post(f"{TELEGRAM_API_URL}/editMessageCaption", json={
"chat_id": channel_id_to_announce,
"message_id": main_message_id,
"caption": main_announcement,
"reply_markup": keyboard,
"parse_mode": "Markdown"
"parse_mode": "HTML"
})
else:
url = f"https://t.me/{BOT_NAME}?start=join_{raffle_id}"
@@ -247,22 +247,22 @@ def receive_paypal_payment(invoice_id, payment_status, payment_amount_str):
main_announcement = f"🏆 Sorteo '{raffle_name}' en progreso 🏆\n\n"
main_announcement += f"{raffle_details['description']}\n\n"
main_announcement += f"🌍 Envío internacional: {'Sí ✅' if raffle_details['international_shipping'] else 'No ❌'}\n"
main_announcement += f"💵 **Donación mínima:** {raffle_details['price']}\n"
main_announcement += f"💵 <b>Donación mínima:</b> {raffle_details['price']}\n"
main_announcement += f"🗒️ Quedan {remaining_numbers_amount} participaciones disponibles. ¡Date prisa! 🗒️\n\n"
main_announcement += f"📜 Normas y condiciones: {TYC_DOCUMENT_URL}"
main_announcement += f"📜 <b>Normas y condiciones:</b> {TYC_DOCUMENT_URL}"
main_message_id = get_main_message_id(raffle_id)
requests.post(f"{TELEGRAM_API_URL}/editMessageCaption", json={
"chat_id": channel_id_to_announce,
"message_id": main_message_id,
"caption": main_announcement,
"reply_markup": keyboard,
"parse_mode": "Markdown"
"parse_mode": "HTML"
})
last_other_participants = get_last_n_other_participants(raffle_id, n=4)
last_participants_text = format_last_participants_list(last_other_participants)
escaped_current_user_name = escape_markdown_v2_chars_for_username(current_user_name)
escaped_current_user_name = current_user_name
numbers_text = ""
if len(numbers) > 1:
@@ -317,7 +317,7 @@ def receive_paypal_payment(invoice_id, payment_status, payment_amount_str):
logger.warning(f"Error deleting old message {update_message_id}: {e_del}. Will send new.")
# Always send new photo after delete attempt, ensures updated image is shown
new_msg_info = send_telegram_photo(channel_id_to_announce, image_path, caption=caption, keyboard=keyboard, parse_mode='Markdown')
new_msg_info = send_telegram_photo(channel_id_to_announce, image_path, caption=caption, keyboard=keyboard, parse_mode='HTML')
if new_msg_info and isinstance(new_msg_info, dict) and 'message_id' in new_msg_info: # If send_telegram_photo returns message object
sent_or_edited_message_id = new_msg_info['message_id']
elif isinstance(new_msg_info, bool) and new_msg_info is True: # If it just returns True/False
@@ -328,7 +328,7 @@ def receive_paypal_payment(invoice_id, payment_status, payment_amount_str):
else: # No previous message, send new
logger.info(f"No previous message found for raffle {raffle_id} in channel {channel_id_to_announce}. Sending new.")
new_msg_info = send_telegram_photo(channel_id_to_announce, image_path, caption=caption, keyboard=keyboard, parse_mode='Markdown')
new_msg_info = send_telegram_photo(channel_id_to_announce, image_path, caption=caption, keyboard=keyboard, parse_mode='HTML')
# Similar logic to get sent_or_edited_message_id as above
if new_msg_info and isinstance(new_msg_info, dict) and 'message_id' in new_msg_info:
sent_or_edited_message_id = new_msg_info['message_id']