diff --git a/src/tg_bot.py b/src/tg_bot.py index 180850f..9fb1bd5 100644 --- a/src/tg_bot.py +++ b/src/tg_bot.py @@ -24,11 +24,12 @@ def send_summary(tg_cfg: TelegramConfig, chat_id: str, summary_text: str, can_reply = summary_data.get("can_reply", True) is_promotion = summary_data.get("category") == "promotion" links = summary_data.get("links", []) + verification_code = summary_data.get("verification_code", "") result = _tg_req(tg_cfg, "sendMessage", { "chat_id": chat_id, "text": summary_text, "parse_mode": "MarkdownV2", - "reply_markup": _summary_keyboard(can_reply, is_promotion, links), + "reply_markup": _summary_keyboard(can_reply, is_promotion, links, verification_code), }) msg_id = result["result"]["message_id"] _email_contexts[msg_id] = { @@ -153,7 +154,8 @@ CALLBACK_HINT = "h" CALLBACK_CANCEL = "c" -def _summary_keyboard(can_reply: bool = True, is_promotion: bool = False, links: list = None) -> dict: +def _summary_keyboard(can_reply: bool = True, is_promotion: bool = False, + links: list = None, verification_code: str = "") -> dict: if is_promotion: return {"inline_keyboard": [[{"text": "查看原文", "callback_data": CALLBACK_VIEW_ORIG}]]} kb = [ @@ -169,6 +171,9 @@ def _summary_keyboard(can_reply: bool = True, is_promotion: bool = False, links: text = link.get("text", "打开链接")[:30] if url.startswith("http"): kb.append([{"text": f"🔗 {text}", "url": url}]) + if verification_code: + code = verification_code.split(" ", 1)[-1] if " " in verification_code else verification_code + kb.append([{"text": f"📋 复制验证码 {code}", "type": "copy_text", "text": code}]) return {"inline_keyboard": kb}