From 6e14160b7d0dd17ad5fa4d294567d46ecf564250 Mon Sep 17 00:00:00 2001 From: Joan Date: Mon, 13 Nov 2023 11:40:45 +0100 Subject: [PATCH] Fixed old message udpate --- conjuntasbot/conjuntasbot.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conjuntasbot/conjuntasbot.py b/conjuntasbot/conjuntasbot.py index 1e657eb..0c043b2 100644 --- a/conjuntasbot/conjuntasbot.py +++ b/conjuntasbot/conjuntasbot.py @@ -410,16 +410,19 @@ async def update_conjunta(update: Update, context: CallbackContext, conjunta_id) message += f"@{user_name} - {quantity} {quantity_string}\n" if (int(time.time()) - int(message_date)) < (24 * 3600 * 2): # borramos el mensaje si tiene más de 1 día + logging.info(f"Updating message for {product_name} - {conjunta_id}") try: await context.bot.edit_message_caption(chat_id=group_chat_id, message_id=message_id, caption=message, parse_mode=ParseMode.HTML) except Exception as e: logging.error(f"Error editing message: {e}") else: + logging.info(f"Original message for {product_name} - {conjunta_id} is old, unpinning and sending new message") await context.bot.unpin_chat_message(chat_id=group_chat_id, message_id=message_id) sent_message = await context.bot.send_photo(chat_id=group_chat_id, photo=photo_id, caption=message, parse_mode=ParseMode.HTML) await context.bot.pin_chat_message(chat_id=group_chat_id, message_id=sent_message.message_id, disable_notification=True) cursor.execute("UPDATE conjuntas SET message_id = ?, message_date = ? WHERE id = ?", (sent_message.message_id, int(time.time()), conjunta_id)) conn.commit() + logging.info("New message sent and pinned") # Función para unirse a una conjunta async def handle_conjunta(update: Update, context: CallbackContext):