diff --git a/homelab-ai-bot/telegram_bot.py b/homelab-ai-bot/telegram_bot.py index c01c7686..bf684e60 100644 --- a/homelab-ai-bot/telegram_bot.py +++ b/homelab-ai-bot/telegram_bot.py @@ -446,27 +446,27 @@ async def handle_message(update: Update, ctx: ContextTypes.DEFAULT_TYPE): sent = True if not sent and suggest["type"] is None: - matched_cand = _find_matching_item(text, memory_client.get_candidates()) - if matched_cand: - log.info("Fallback-Match: Kandidat ID=%s", matched_cand["id"]) - await update.message.reply_text( - answer[:4000] + "\n\n" + _format_candidate(matched_cand), - reply_markup=_memory_buttons(matched_cand["id"]), - ) + from datetime import datetime as _dt + matched_active = _find_matching_item(text, memory_client.get_active_memory()) + if matched_active: + mtype = matched_active.get("memory_type", "") + exp = matched_active.get("expires_at") + if mtype == "temporary" and exp: + status_msg = f"\n\n🕒 Schon temporär gespeichert bis {_dt.fromtimestamp(exp).strftime('%d.%m.%Y')}." + elif mtype == "permanent": + status_msg = "\n\n📌 Schon dauerhaft gespeichert." + else: + status_msg = "\n\n✅ Bereits gespeichert." + await update.message.reply_text(answer[:3900] + status_msg, reply_markup=KEYBOARD) sent = True else: - matched_active = _find_matching_item(text, memory_client.get_active_memory()) - if matched_active: - from datetime import datetime as _dt - mtype = matched_active.get("memory_type", "") - exp = matched_active.get("expires_at") - if mtype == "temporary" and exp: - status_msg = f"\n\n🕒 Schon temporär gespeichert bis {_dt.fromtimestamp(exp).strftime('%d.%m.%Y')}." - elif mtype == "permanent": - status_msg = "\n\n📌 Schon dauerhaft gespeichert." - else: - status_msg = "\n\n✅ Bereits gespeichert." - await update.message.reply_text(answer[:3900] + status_msg, reply_markup=KEYBOARD) + matched_cand = _find_matching_item(text, memory_client.get_candidates()) + if matched_cand: + log.info("Fallback-Match: Kandidat ID=%s", matched_cand["id"]) + await update.message.reply_text( + answer[:4000] + "\n\n" + _format_candidate(matched_cand), + reply_markup=_memory_buttons(matched_cand["id"]), + ) sent = True if not sent: