Fixed old message udpate
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user