mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50:30 +08:00
fix telegram actions
This commit is contained in:
parent
195ed68152
commit
636a59ec91
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@ -224,6 +224,14 @@ jobs:
|
||||
if: startsWith(github.ref, 'refs/heads/')
|
||||
needs: [windows, macos, linux, windows7]
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
telegram-bot-api:
|
||||
image: aiogram/telegram-bot-api:latest
|
||||
env:
|
||||
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_BOT_API_ID }}
|
||||
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_BOT_API_HASH }}
|
||||
ports:
|
||||
- 8081:8081
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@ -235,11 +243,6 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
merge-multiple: true
|
||||
- name: Telegram Bot Server
|
||||
uses: zjns/telegram-bot-server@v1
|
||||
with:
|
||||
api_id: ${{ secrets.TELEGRAM_BOT_API_ID }}
|
||||
api_hash: ${{ secrets.TELEGRAM_BOT_API_HASH }}
|
||||
- name: Upload Artifacts
|
||||
env:
|
||||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
import fs from 'fs'
|
||||
import axios from 'axios'
|
||||
import path from 'path'
|
||||
@ -87,32 +88,42 @@ macosFiles.forEach((file, index) => {
|
||||
macosForm.append(`file${index}`, fs.createReadStream(file))
|
||||
})
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
await axios.post(
|
||||
`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`,
|
||||
`http://127.0.0.1:8081/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`,
|
||||
windowsForm,
|
||||
{
|
||||
headers: windowsForm.getHeaders()
|
||||
}
|
||||
)
|
||||
|
||||
await sleep(10000)
|
||||
|
||||
await axios.post(
|
||||
`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`,
|
||||
`http://127.0.0.1:8081/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`,
|
||||
windows7Form,
|
||||
{
|
||||
headers: windows7Form.getHeaders()
|
||||
}
|
||||
)
|
||||
|
||||
await sleep(10000)
|
||||
|
||||
await axios.post(
|
||||
`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`,
|
||||
`http://127.0.0.1:8081/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`,
|
||||
macosForm,
|
||||
{
|
||||
headers: macosForm.getHeaders()
|
||||
}
|
||||
)
|
||||
|
||||
await sleep(10000)
|
||||
|
||||
await axios.post(
|
||||
`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`,
|
||||
`http://127.0.0.1:8081/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`,
|
||||
linuxForm,
|
||||
{
|
||||
headers: linuxForm.getHeaders()
|
||||
|
||||
@ -31,9 +31,7 @@ content += `DEB:<a href="${downloadUrl}/mihomo-party-linux-${version}-amd64.de
|
||||
">64位</a> | <a href="${downloadUrl}/mihomo-party-linux-${version}-arm64.deb">ARM64</a>\n`
|
||||
content += `RPM:<a href="${downloadUrl}/mihomo-party-linux-${version}-x86_64.rpm">64位</a> | <a href="${downloadUrl}/mihomo-party-linux-${version}-aarch64.rpm">ARM64</a>`
|
||||
|
||||
const { data: messageData } = await axios.post(
|
||||
`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`,
|
||||
{
|
||||
await axios.post(`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, {
|
||||
chat_id,
|
||||
text: content,
|
||||
link_preview_options: {
|
||||
@ -42,27 +40,4 @@ const { data: messageData } = await axios.post(
|
||||
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
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user