feat: AI reply suggestions show as copyable code block, user edits before sending - Click suggestion -> show text in backtick code block (tap to copy) - Enter awaiting_reply state so user can edit/send like normal reply - No direct email sending on selection anymore - Tests: 3/3 passing
This commit is contained in:
@@ -382,16 +382,26 @@ def _handle_callback(tg_cfg: TelegramConfig, cfg: Config, cb: dict):
|
|||||||
if idx >= len(suggestions):
|
if idx >= len(suggestions):
|
||||||
return
|
return
|
||||||
sel = suggestions[idx]
|
sel = suggestions[idx]
|
||||||
logger.info(" 选择回复 #%d: %s", idx, sel["text"][:60])
|
sel_text = sel["text"]
|
||||||
_do_send_reply(tg_cfg, cfg, chat_id, msg_id, ctx, sel["text"])
|
logger.info(" 选择回复 #%d: %s", idx, sel_text[:60])
|
||||||
send_text(tg_cfg, str(chat_id), f"✅ 已发送: {sel['text']}")
|
|
||||||
delete_conversation(chat_id)
|
# 用代码块显示,点击可复制
|
||||||
can_reply = ctx.get("can_reply", True)
|
escaped = sel_text.replace("\\", "\\\\").replace("`", "\\`")
|
||||||
_tg_req(tg_cfg, "editMessageText", {
|
copy_msg = send_text(tg_cfg, str(chat_id),
|
||||||
"chat_id": chat_id, "message_id": msg_id,
|
f"*建议回复(点击代码块复制):*\n`{escaped}`")
|
||||||
"text": ctx["summary_text"], "parse_mode": "MarkdownV2",
|
|
||||||
"reply_markup": _summary_keyboard(can_reply),
|
# 进入 awaiting_reply 状态,用户可编辑后发送
|
||||||
})
|
prompt_msg_id = send_text(
|
||||||
|
tg_cfg, str(chat_id),
|
||||||
|
"请编辑后发送(或直接回复附件):",
|
||||||
|
reply_markup=_cancel_keyboard(),
|
||||||
|
)
|
||||||
|
conv["state"] = "awaiting_reply"
|
||||||
|
conv["summary_msg_id"] = msg_id
|
||||||
|
conv["prompt_msg_id"] = prompt_msg_id
|
||||||
|
conv["draft_text"] = sel_text
|
||||||
|
save_conversation(chat_id, conv)
|
||||||
|
logger.info(" 建议已展示,等待用户编辑发送")
|
||||||
|
|
||||||
elif action == CALLBACK_REGEN and ctx:
|
elif action == CALLBACK_REGEN and ctx:
|
||||||
conv = load_conversation(chat_id)
|
conv = load_conversation(chat_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user