mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-14 21:20:48 +08:00
chore: trim excessive comments
This commit is contained in:
+1
-12
@@ -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 '<'
|
||||
if (token === '>') return '>'
|
||||
// Keep supported tags; escape everything else so it displays as text.
|
||||
return allowedTag.test(token)
|
||||
? token
|
||||
: token.replace(/</g, '<').replace(/>/g, '>')
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user