mihomo-party/scripts/telegram.mjs

27 lines
902 B
JavaScript
Raw Normal View History

2024-09-08 14:56:13 +08:00
import axios from 'axios'
import { readFileSync } from 'fs'
const pkg = readFileSync('package.json', 'utf-8')
const changelog = readFileSync('changelog.md', 'utf-8')
const { version } = JSON.parse(pkg)
2024-09-13 20:24:52 +08:00
let content = `<b>🌟 <a href="https://github.com/mihomo-party-org/mihomo-party/releases/tag/v${version}">Mihomo Party v${version}</a> 正式发布</b>\n\n`
2024-09-08 14:56:13 +08:00
for (const line of changelog.split('\n')) {
if (line.length === 0) {
content += '\n'
} else if (line.startsWith('### ')) {
content += `<b>${line.replace('### ', '')}</b>\n`
} else {
content += `${line}\n`
}
}
axios.post(`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, {
chat_id: '@mihomo_party_channel',
text: content,
2024-09-11 11:26:51 +08:00
link_preview_options: {
is_disabled: false,
2024-09-13 20:24:52 +08:00
url: 'https://github.com/mihomo-party-org/mihomo-party',
2024-09-11 11:26:51 +08:00
prefer_large_media: true
},
parse_mode: 'HTML'
2024-09-08 14:56:13 +08:00
})