feat: verification emails displayed as platform + code
This commit is contained in:
@@ -17,6 +17,7 @@ SYSTEM_PROMPT = """你是一个邮件摘要助手。请分析邮件内容并以
|
||||
"sender": "发件人",
|
||||
"category": "normal/promotion/notification",
|
||||
"summary": "50字以内的核心摘要",
|
||||
"verification_code": "",
|
||||
"priority": "high/medium/low",
|
||||
"action_required": true/false,
|
||||
"action_items": ["待办事项1", "待办事项2"],
|
||||
@@ -31,7 +32,8 @@ SYSTEM_PROMPT = """你是一个邮件摘要助手。请分析邮件内容并以
|
||||
|
||||
其中:
|
||||
- subject 不能照抄原邮件主题,必须是你总结生成的简短标题
|
||||
- category: 邮件类型。推广邮件(营销、促销、广告、 newsletter 推广等)标记为 "promotion";系统通知类(账单、验证码、订阅提醒等)标记为 "notification";普通邮件标记为 "normal"
|
||||
- category: 邮件类型。推广邮件(营销、促销、广告、 newsletter 推广等)标记为 "promotion";验证码邮件标记为 "notification";普通邮件标记为 "normal"
|
||||
- verification_code: 仅当 category 为 "notification" 且邮件包含验证码时填写,格式为「平台名称 验证码」(如「GitHub 123456」「微信 888888」)。非验证码邮件留空字符串
|
||||
- 当 category 为 "promotion" 时,summary 直接写成一句话:「[发送方名称] 在推广 [推广的产品/服务/活动]」,例如「腾讯云在推广双十一云服务器折扣」。此时 priority 固定为 "low",action_required 为 false,can_reply 为 false,action_items 和 reply_suggestions 为空数组
|
||||
- can_reply 为 false 表示无需回复或不适合建议回复(此时忽略 reply_suggestions)
|
||||
- is_simple 为 true 表示纯确认性回复(如"好的""收到"),用户选择后可直发
|
||||
|
||||
@@ -26,10 +26,12 @@ def send_summary(tg_cfg: TelegramConfig, chat_id: str, summary_text: str,
|
||||
original_reply_to: str = "", account_email: str = "") -> int:
|
||||
can_reply = summary_data.get("can_reply", True)
|
||||
is_promotion = summary_data.get("category") == "promotion"
|
||||
is_verification = summary_data.get("category") == "notification" and summary_data.get("verification_code")
|
||||
plain_text = is_promotion or is_verification
|
||||
result = _tg_req(tg_cfg, "sendMessage", {
|
||||
"chat_id": chat_id,
|
||||
"text": summary_text,
|
||||
"parse_mode": "MarkdownV2" if not is_promotion else None,
|
||||
"parse_mode": "MarkdownV2" if not plain_text else None,
|
||||
"reply_markup": _summary_keyboard(can_reply, is_promotion),
|
||||
})
|
||||
msg_id = result["result"]["message_id"]
|
||||
@@ -97,6 +99,8 @@ def format_summary(data: dict, account_email: str = "") -> str:
|
||||
category = data.get("category", "normal")
|
||||
if category == "promotion":
|
||||
return _format_promotion(data, account_email)
|
||||
if category == "notification" and data.get("verification_code"):
|
||||
return _format_verification(data, account_email)
|
||||
return _format_normal(data, account_email)
|
||||
|
||||
|
||||
@@ -109,6 +113,15 @@ def _format_promotion(data: dict, account_email: str = "") -> str:
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def _format_verification(data: dict, account_email: str = "") -> str:
|
||||
code = data.get("verification_code", "")
|
||||
lines = [
|
||||
f"🔑 {_escape(code)}",
|
||||
f"账户: {_escape(account_email)}",
|
||||
]
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def _format_normal(data: dict, account_email: str = "") -> str:
|
||||
priority = data.get("priority", "medium")
|
||||
icon = _priority_icon.get(priority, "⚪")
|
||||
|
||||
Reference in New Issue
Block a user