Skip to content

Commit

Permalink
1.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
pompurin404 committed Oct 11, 2024
1 parent 2f1eabc commit 61847d9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mihomo-party",
"version": "1.4.4",
"version": "1.4.5",
"description": "Mihomo Party",
"main": "./out/main/index.js",
"author": "mihomo-party",
Expand Down
45 changes: 36 additions & 9 deletions scripts/telegram.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios'
import { readFileSync } from 'fs'

const chat_id = '@mihomo_party_group'
const pkg = readFileSync('package.json', 'utf-8')
const changelog = readFileSync('changelog.md', 'utf-8')
const { version } = JSON.parse(pkg)
Expand All @@ -14,13 +15,39 @@ for (const line of changelog.split('\n')) {
content += `${line}\n`
}
}
axios.post(`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, {
chat_id: '@mihomo_party_group',
text: content,
link_preview_options: {
is_disabled: false,
url: 'https://github.com/mihomo-party-org/mihomo-party',
prefer_large_media: true
},
parse_mode: 'HTML'

const { data: messageData } = await axios.post(
`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`,
{
chat_id,
text: content,
link_preview_options: {
is_disabled: false,
url: 'https://github.com/mihomo-party-org/mihomo-party',
prefer_large_media: true
},
parse_mode: 'HTML'
}
)

const { data: chatData } = await axios.post(
`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/getChat`,
{
chat_id
}
)

if (chatData.result.pinned_message.from.is_bot) {
await axios.post(
`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/unpinChatMessage`,
{
chat_id,
message_id: chatData.result.pinned_message.message_id
}
)
}

await axios.post(`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/pinChatMessage`, {
chat_id,
message_id: messageData.result.message_id
})

0 comments on commit 61847d9

Please sign in to comment.