fix(telegram): render HTML with markdown-it and strip HTML from Discord bodies

This commit is contained in:
RhenCloud 2026-08-18 18:29:17 +08:00
parent ea049e28c9
commit 9899cd01bf
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
7 changed files with 90 additions and 18 deletions

View file

@ -1,6 +1,6 @@
import type { NeutralMessage, NeutralAuthor } from "../types";
import { GITHUB_COLORS } from "./colors";
import { cap, emojiPrefix, MAX_FIELD_VALUE, type T, buildMessage } from "./helpers";
import { cap, emojiPrefix, htmlToText, MAX_FIELD_VALUE, type T, buildMessage } from "./helpers";
export function formatIssues(
payload: Record<string, unknown>,
@ -38,7 +38,7 @@ export function formatIssues(
descriptionParts.push(t("events.issues.action_issue", { emoji: em(stateEmoji), action: al }));
if (issue.body) {
const truncated = issue.body.slice(0, 300);
const truncated = htmlToText(issue.body).slice(0, 300);
descriptionParts.push(`\n${truncated}${issue.body.length > 300 ? "..." : ""}`);
}