feat: verification emails displayed as platform + code
This commit is contained in:
@@ -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