Fixed old message udpate

This commit is contained in:
Joan
2023-11-13 11:43:55 +01:00
parent 6e14160b7d
commit 60aa369baf

View File

@@ -417,7 +417,10 @@ async def update_conjunta(update: Update, context: CallbackContext, conjunta_id)
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")
try:
await context.bot.unpin_chat_message(chat_id=group_chat_id, message_id=message_id)
except Exception as e:
logging.error(f"Error unpinning message: {e}")
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))
@@ -460,8 +463,8 @@ async def handle_conjunta(update: Update, context: CallbackContext):
await send_message_to_admins(update, context, f"@{user_name} se ha desapuntado de la conjunta {product_name} - {conjunta_id}")
try:
await update_conjunta(update, context, conjunta_id)
except Exception:
pass
except Exception as e:
logging.error(f"Error updating conjunta: {e}")
else:
await update.message.reply_text("La conjunta ya está cerrada y no puedes borrarte.")