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):
|
||||
return
|
||||
sel = suggestions[idx]
|
||||
logger.info(" 选择回复 #%d: %s", idx, sel["text"][:60])
|
||||
_do_send_reply(tg_cfg, cfg, chat_id, msg_id, ctx, sel["text"])
|
||||
send_text(tg_cfg, str(chat_id), f"✅ 已发送: {sel['text']}")
|
||||
delete_conversation(chat_id)
|
||||
can_reply = ctx.get("can_reply", True)
|
||||
_tg_req(tg_cfg, "editMessageText", {
|
||||
"chat_id": chat_id, "message_id": msg_id,
|
||||
"text": ctx["summary_text"], "parse_mode": "MarkdownV2",
|
||||
"reply_markup": _summary_keyboard(can_reply),
|
||||
})
|
||||
sel_text = sel["text"]
|
||||
logger.info(" 选择回复 #%d: %s", idx, sel_text[:60])
|
||||
|
||||
# 用代码块显示,点击可复制
|
||||
escaped = sel_text.replace("\\", "\\\\").replace("`", "\\`")
|
||||
copy_msg = send_text(tg_cfg, str(chat_id),
|
||||
f"*建议回复(点击代码块复制):*\n`{escaped}`")
|
||||
|
||||
# 进入 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:
|
||||
conv = load_conversation(chat_id)
|
||||
|
||||
Reference in New Issue
Block a user