mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 03:32:17 +08:00
add telegram notification
This commit is contained in:
parent
1962414ed6
commit
2843bf94b2
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
|
@ -202,6 +202,10 @@ jobs:
|
|||
version: 9
|
||||
- name: Build Latest
|
||||
run: pnpm install && pnpm updater
|
||||
- name: Telegram Notification
|
||||
env:
|
||||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||
run: pnpm temegram
|
||||
- name: Publish Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
<a href="https://github.com/pompurin404/mihomo-party/releases">
|
||||
<img src="https://img.shields.io/github/release/pompurin404/mihomo-party/all.svg">
|
||||
</a>
|
||||
<a href="https://t.me/mihomo_party">
|
||||
<img src="https://img.shields.io/badge/Telegram-group-blue?logo=telegram">
|
||||
<a href="https://t.me/mihomo_party_channel">
|
||||
<img src="https://img.shields.io/badge/Telegram-Channel-blue?logo=telegram">
|
||||
</a>
|
||||
</p>
|
||||
<div align='center'>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"prepare": "node scripts/prepare.mjs",
|
||||
"updater": "node scripts/updater.mjs",
|
||||
"checksum": "node scripts/checksum.mjs",
|
||||
"telegram": "node scripts/telegram.mjs",
|
||||
"dev": "electron-vite dev",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"build:win": "electron-vite build && electron-builder --publish never --win",
|
||||
|
|
47
scripts/telegram.mjs
Normal file
47
scripts/telegram.mjs
Normal file
|
@ -0,0 +1,47 @@
|
|||
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)
|
||||
let content = `<b>🌟Mihomo Party v${version} 正式发布</b>\n\n`
|
||||
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,
|
||||
parse_mode: 'HTML',
|
||||
reply_markup: {
|
||||
inline_keyboard: [
|
||||
[
|
||||
{
|
||||
text: '官方群组',
|
||||
url: 'https://t.me/mihomo_party'
|
||||
},
|
||||
{
|
||||
text: '官方频道',
|
||||
url: 'https://t.me/mihomo_party_channel'
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
text: '官方文档',
|
||||
url: 'https://mihomo.party'
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
text: '前往下载',
|
||||
url: `https://github.com/pompurin404/mihomo-party/releases/tag/v${version}`
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user