diff --git a/src/tg_bot.py b/src/tg_bot.py index ca056e2..f98fee9 100644 --- a/src/tg_bot.py +++ b/src/tg_bot.py @@ -365,7 +365,13 @@ def _handle_callback(bot_token: str, cfg: Config, cb: dict): if action == CALLBACK_VIEW_ORIG and ctx: can_reply = ctx.get("can_reply", True) - text = f"*📄 原文 \\- {_escape(ctx['subject'])}*\n\n{_escape(ctx.get('plain_text', ctx['original_body']))}" + subject = ctx.get("subject", "邮件") + body = ctx.get("plain_text", ctx["original_body"]) + if len(body) > 3500: + body = body[:3500] + "\n\n... (内容过长已截断)" + # 用代码块包裹原文,避免 MarkdownV2 解析特殊字符 + escaped_body = body.replace("\\", "\\\\").replace("`", "\\`") + text = f"*📄 原文 \\- {_escape(subject)}*\n\n`{escaped_body}`" _tg_req(bot_token, "editMessageText", { "chat_id": chat_id, "message_id": msg_id, "text": text, "parse_mode": "MarkdownV2",