Compare commits
2 Commits
51064e48aa
...
6ce9a806ea
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ce9a806ea | |||
| 84f2428aeb |
@@ -356,11 +356,23 @@ def _handle_callback(tg_cfg: TelegramConfig, cfg: Config, cb: dict):
|
||||
logger.info(" 进入回复流程, prompt_msg_id=%d", prompt_msg_id)
|
||||
|
||||
elif action in (CALLBACK_AI_REPLY_FULL, CALLBACK_AI_REPLY_SHORT) and ctx:
|
||||
suggestions = ctx["summary_data"].get("reply_suggestions", [])
|
||||
style = "full" if action == CALLBACK_AI_REPLY_FULL else "short"
|
||||
suggestions = ctx["summary_data"].get("reply_suggestions", [])
|
||||
|
||||
# 缓存为空时重新生成
|
||||
if not suggestions:
|
||||
send_text(tg_cfg, str(chat_id), "此邮件无需回复。")
|
||||
logger.info(" AI 判定无需回复,隐藏")
|
||||
logger.info(" 缓存为空,重新生成 AI 回复 (style=%s)", style)
|
||||
_tg_req(tg_cfg, "editMessageText", {
|
||||
"chat_id": chat_id, "message_id": msg_id,
|
||||
"text": "🤖 *AI思考中…*", "parse_mode": "MarkdownV2",
|
||||
})
|
||||
conv = load_conversation(chat_id) or {}
|
||||
conv["state"] = "ai_reply_selection"
|
||||
conv["summary_msg_id"] = msg_id
|
||||
conv["reply_style"] = style
|
||||
conv["all_suggestions"] = []
|
||||
save_conversation(chat_id, conv)
|
||||
_ai_pool.submit(_do_regen, cfg, chat_id, msg_id, ctx, conv)
|
||||
return
|
||||
|
||||
save_conversation(chat_id, {
|
||||
@@ -385,10 +397,13 @@ def _handle_callback(tg_cfg: TelegramConfig, cfg: Config, cb: dict):
|
||||
sel_text = sel["text"]
|
||||
logger.info(" 选择回复 #%d: %s", idx, sel_text[:60])
|
||||
|
||||
# 用代码块显示,点击可复制
|
||||
# 用代码块显示,点击可复制(MarkdownV2)
|
||||
escaped = sel_text.replace("\\", "\\\\").replace("`", "\\`")
|
||||
copy_msg = send_text(tg_cfg, str(chat_id),
|
||||
f"*建议回复(点击代码块复制):*\n`{escaped}`")
|
||||
_tg_req(tg_cfg, "sendMessage", {
|
||||
"chat_id": str(chat_id),
|
||||
"text": f"*建议回复(点击代码块复制):*\n`{escaped}`",
|
||||
"parse_mode": "MarkdownV2",
|
||||
})
|
||||
|
||||
# 进入 awaiting_reply 状态,用户可编辑后发送
|
||||
prompt_msg_id = send_text(
|
||||
@@ -430,7 +445,10 @@ def _handle_callback(tg_cfg: TelegramConfig, cfg: Config, cb: dict):
|
||||
|
||||
elif action == CALLBACK_CANCEL:
|
||||
delete_conversation(chat_id)
|
||||
# 清除回复建议缓存,重新选择时会重新生成
|
||||
if ctx:
|
||||
ctx["summary_data"]["reply_suggestions"] = []
|
||||
save_email_context(msg_id, ctx)
|
||||
can_reply = ctx.get("can_reply", True)
|
||||
_tg_req(tg_cfg, "editMessageText", {
|
||||
"chat_id": chat_id, "message_id": msg_id,
|
||||
|
||||
Reference in New Issue
Block a user