chore: trim excessive comments

This commit is contained in:
wonfen
2026-08-19 07:27:43 +08:00
parent 42b91b6294
commit 807f9a206d
103 changed files with 293 additions and 2517 deletions
+1 -12
View File
@@ -32,7 +32,6 @@ async function sendTelegramNotification() {
log_info(`Target channel: ${chatId}`)
log_info(`Download URL: ${downloadUrl}`)
// 读取发布说明和下载地址
let releaseContent
try {
releaseContent = readFileSync('release.txt', 'utf-8')
@@ -42,7 +41,6 @@ async function sendTelegramNotification() {
releaseContent = '更多新功能现已支持,详细更新日志请查看发布页面。'
}
// Markdown 转换为 HTML
function convertMarkdownToTelegramHTML(content) {
// Strip stray HTML tags and markdown bold from heading text
const cleanHeading = (text) =>
@@ -88,20 +86,13 @@ async function sendTelegramNotification() {
.replace(/<br\s*\/?>/g, '\n')
}
// Strip HTML tags not supported by Telegram and escape stray angle brackets
function sanitizeTelegramHTML(content) {
// Telegram supports: b, strong, i, em, u, ins, s, strike, del,
// a, code, pre, blockquote, tg-spoiler, tg-emoji
const allowedTag =
/^<\/?(?:b|strong|i|em|u|ins|s|strike|del|a|code|pre|blockquote|tg-spoiler|tg-emoji)(?:\s[^<>]*)?>$/i
// Match a well-formed tag (name first, no nested angle brackets) OR a lone
// '<'/'>'. Matching lone brackets is what keeps a stray '<' in the changelog
// (e.g. "原始配置 < Merge") from greedily swallowing the next real tag and
// leaving its closing tag orphaned ("Unexpected end tag").
// Match tags or lone brackets separately so stray changelog text cannot swallow a real tag.
return content.replace(/<\/?[a-z][^<>]*>|[<>]/gi, (token) => {
if (token === '<') return '&lt;'
if (token === '>') return '&gt;'
// Keep supported tags; escape everything else so it displays as text.
return allowedTag.test(token)
? token
: token.replace(/</g, '&lt;').replace(/>/g, '&gt;')
@@ -118,7 +109,6 @@ async function sendTelegramNotification() {
const releaseTag = isAutobuild ? 'autobuild' : `v${version}`
const content = `<b>🎉 <a href="https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/${releaseTag}">Clash Verge Rev v${version}</a> ${releaseTitle}</b>\n\n${formattedContent}`
// 发送到 Telegram
try {
await axios.post(
`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`,
@@ -144,7 +134,6 @@ async function sendTelegramNotification() {
}
}
// 执行函数
sendTelegramNotification().catch((error) => {
log_error('脚本执行失败:', error)
process.exit(1)