From cf0f7d3956bc11502622bfa6c61c137321a4ace8 Mon Sep 17 00:00:00 2001 From: Zichao Lin Date: Sat, 11 Jul 2026 22:11:15 +0800 Subject: [PATCH] =?UTF-8?q?style:=20restructure=20email=20formats=20with?= =?UTF-8?q?=20=E6=94=B6=E4=BB=B6=E8=B4=A6=E6=88=B7=20and=20app=5Fname=20fo?= =?UTF-8?q?r=20verification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ai_client.py | 4 +++- src/tg_bot.py | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ai_client.py b/src/ai_client.py index 6c895b3..2dce0fd 100644 --- a/src/ai_client.py +++ b/src/ai_client.py @@ -18,6 +18,7 @@ SYSTEM_PROMPT = """你是一个邮件摘要助手。请分析邮件内容并以 "category": "normal/promotion/notification", "summary": "50字以内的核心摘要", "verification_code": "", + "app_name": "", "links": [{"text": "按钮文字", "url": "https://..."}], "can_reply": true/false, "reply_suggestions": [ @@ -30,7 +31,8 @@ SYSTEM_PROMPT = """你是一个邮件摘要助手。请分析邮件内容并以 其中: - subject 不能照抄原邮件主题,必须是你总结生成的简短标题 - category: 邮件类型。推广邮件(营销、促销、广告、 newsletter 推广等)标记为 "promotion";验证码邮件标记为 "notification";普通邮件标记为 "normal" -- verification_code: 仅当 category 为 "notification" 且邮件包含验证码时填写,格式为「平台名称 验证码」(如「GitHub 123456」「微信 888888」)。非验证码邮件留空字符串 +- verification_code: 仅当 category 为 "notification" 且邮件包含验证码时填写,只填纯数字验证码(如「123456」「888888」),不包含平台名。非验证码邮件留空字符串 +- app_name: 仅当 category 为 "notification" 且邮件包含验证码时填写,填写发送验证码的应用/平台名称(如「GitHub」「微信」「Kraken」)。非验证码邮件留空字符串 - links: 从邮件正文中提取用户需要点击的链接。只提取有意义的、用户可能需要操作的链接(如确认链接、登录链接、下载链接、账单链接等),不要提取退订链接、追踪像素、邮件头中的无关链接。每条包含简短描述文字和完整 URL。最多 3 条。没有需要点击的链接时为空数组 - summary 要简洁,把需要知道的信息浓缩成一句话,不需要分条列出 - 当 category 为 "promotion" 时,summary 直接写成一句话:「[发送方名称] 在推广 [推广的产品/服务/活动]」,例如「腾讯云在推广双十一云服务器折扣」。此时 can_reply 为 false,reply_suggestions 为空数组 diff --git a/src/tg_bot.py b/src/tg_bot.py index 03b56f9..e6e4dcb 100644 --- a/src/tg_bot.py +++ b/src/tg_bot.py @@ -105,19 +105,22 @@ def _format_promotion(data: dict, account_email: str = "") -> str: lines = [ f"📢 *推广*", f"━━━━━━━━━━━━━━━━━━", + f"*收件账户:* {_escape(account_email)}", + "", f"{_escape(summary)}", - f"账户: {_escape(account_email)}", ] return "\n".join(lines) def _format_verification(data: dict, account_email: str = "") -> str: code = data.get("verification_code", "") + app = data.get("app_name", "") lines = [ f"🔑 *验证码*", f"━━━━━━━━━━━━━━━━━━", - f"`{_escape(code)}`", - f"账户: {_escape(account_email)}", + f"*收件账户:* {_escape(account_email)}", + f"*应用:* {_escape(app)}", + f"*验证码:* `{_escape(code)}`", ] return "\n".join(lines) @@ -126,9 +129,9 @@ def _format_normal(data: dict, account_email: str = "") -> str: lines = [ f"📧 *{_escape(data.get('subject', '邮件摘要'))}*", f"━━━━━━━━━━━━━━━━━━", + f"*收件账户:* {_escape(account_email)}", f"*收件人:* {_escape(data.get('recipient', '未知'))}", f"*发件人:* {_escape(data.get('sender', '未知'))}", - f"*账户:* {_escape(account_email)}", "", _escape(data.get("summary", "")), ]