Skip to content

Commit 769cfd8

Browse files
committed
fix(callbacks): handle orphan buttons gracefully when group/news is missing
1 parent d7c5196 commit 769cfd8

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

handlers/callbacks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ async def button(update: Update, context: ContextTypes.DEFAULT_TYPE):
2222
session.delete(group)
2323
action_text = "\n¡Rechazado!"
2424
await query.edit_message_text(text=message.text + action_text)
25+
else:
26+
await query.edit_message_text(text=message.text + "\n[Botón huérfano: El grupo ya no existe en la base de datos]")
2527

2628
elif buttonType == "Noticia":
2729
noticia = session.query(Noticia).filter_by(id=int(id_val)).first()
@@ -35,3 +37,5 @@ async def button(update: Update, context: ContextTypes.DEFAULT_TYPE):
3537
session.delete(noticia)
3638
action_text = "\n¡Rechazado!"
3739
await query.edit_message_text(text=message.text + action_text)
40+
else:
41+
await query.edit_message_text(text=message.text + "\n[Botón huérfano: La noticia ya no existe en la base de datos]")

0 commit comments

Comments
 (0)