feat: three-stage status: 获取邮件中 -> 等待处理 -> AI思考中
This commit is contained in:
@@ -21,14 +21,16 @@ def poll_accounts(cfg: Config, skip_uids: set[bytes] | None = None) -> Generator
|
||||
logger.error(f"轮询 {acct.username} 失败: {e}", exc_info=True)
|
||||
|
||||
|
||||
def ai_process(cfg: Config, acct_idx: int, mail: Email) -> Optional[dict]:
|
||||
def ai_process(cfg: Config, acct_idx: int, mail: Email, tg_msg_id: int = 0) -> Optional[dict]:
|
||||
logger.info(f" 正在摘要: {mail.subject}")
|
||||
# 阶段1:显示获取邮件中
|
||||
msg_id = send_thinking(cfg.telegram, cfg.telegram.chat_id, "📥 获取邮件中...")
|
||||
logger.info(f" 获取邮件中消息已发送: msg_id={msg_id}")
|
||||
# 阶段1:显示等待处理
|
||||
if tg_msg_id:
|
||||
edit_message(cfg.telegram, cfg.telegram.chat_id, tg_msg_id, "⏳ 等待处理...")
|
||||
else:
|
||||
tg_msg_id = send_thinking(cfg.telegram, cfg.telegram.chat_id, "⏳ 等待处理...")
|
||||
|
||||
# 阶段2:AI 处理,更新为思考中
|
||||
edit_message(cfg.telegram, cfg.telegram.chat_id, msg_id, "🤖 AI思考中...")
|
||||
edit_message(cfg.telegram, cfg.telegram.chat_id, tg_msg_id, "🤖 AI思考中...")
|
||||
summary = summarize_email(cfg.ai, mail.recipient, mail.subject, mail.sender, mail.body, mail.account_email)
|
||||
summary["recipient"] = mail.recipient
|
||||
if "@" not in summary.get("sender", ""):
|
||||
@@ -46,7 +48,7 @@ def ai_process(cfg: Config, acct_idx: int, mail: Email) -> Optional[dict]:
|
||||
"account_email": mail.account_email,
|
||||
"uid": mail.uid,
|
||||
"folder": mail.folder,
|
||||
"thinking_msg_id": msg_id,
|
||||
"thinking_msg_id": tg_msg_id if tg_msg_id else 0,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user