Memory: Aktive Items vor Kandidaten pruefen im Fallback, Duplikat ID 19 bereinigt
This commit is contained in:
parent
c3d306e495
commit
b2dd69dd1e
1 changed files with 19 additions and 19 deletions
|
|
@ -446,27 +446,27 @@ async def handle_message(update: Update, ctx: ContextTypes.DEFAULT_TYPE):
|
||||||
sent = True
|
sent = True
|
||||||
|
|
||||||
if not sent and suggest["type"] is None:
|
if not sent and suggest["type"] is None:
|
||||||
matched_cand = _find_matching_item(text, memory_client.get_candidates())
|
from datetime import datetime as _dt
|
||||||
if matched_cand:
|
matched_active = _find_matching_item(text, memory_client.get_active_memory())
|
||||||
log.info("Fallback-Match: Kandidat ID=%s", matched_cand["id"])
|
if matched_active:
|
||||||
await update.message.reply_text(
|
mtype = matched_active.get("memory_type", "")
|
||||||
answer[:4000] + "\n\n" + _format_candidate(matched_cand),
|
exp = matched_active.get("expires_at")
|
||||||
reply_markup=_memory_buttons(matched_cand["id"]),
|
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
|
sent = True
|
||||||
else:
|
else:
|
||||||
matched_active = _find_matching_item(text, memory_client.get_active_memory())
|
matched_cand = _find_matching_item(text, memory_client.get_candidates())
|
||||||
if matched_active:
|
if matched_cand:
|
||||||
from datetime import datetime as _dt
|
log.info("Fallback-Match: Kandidat ID=%s", matched_cand["id"])
|
||||||
mtype = matched_active.get("memory_type", "")
|
await update.message.reply_text(
|
||||||
exp = matched_active.get("expires_at")
|
answer[:4000] + "\n\n" + _format_candidate(matched_cand),
|
||||||
if mtype == "temporary" and exp:
|
reply_markup=_memory_buttons(matched_cand["id"]),
|
||||||
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
|
sent = True
|
||||||
|
|
||||||
if not sent:
|
if not sent:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue