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/')
|
if: startsWith(github.ref, 'refs/heads/')
|
||||||
needs: [windows, macos, linux, windows7]
|
needs: [windows, macos, linux, windows7]
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -235,11 +243,6 @@ jobs:
|
|||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
merge-multiple: true
|
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
|
- name: Upload Artifacts
|
||||||
env:
|
env:
|
||||||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
@ -87,32 +88,42 @@ macosFiles.forEach((file, index) => {
|
|||||||
macosForm.append(`file${index}`, fs.createReadStream(file))
|
macosForm.append(`file${index}`, fs.createReadStream(file))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function sleep(ms) {
|
||||||
|
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||||
|
}
|
||||||
|
|
||||||
await axios.post(
|
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,
|
windowsForm,
|
||||||
{
|
{
|
||||||
headers: windowsForm.getHeaders()
|
headers: windowsForm.getHeaders()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await sleep(10000)
|
||||||
|
|
||||||
await axios.post(
|
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,
|
windows7Form,
|
||||||
{
|
{
|
||||||
headers: windows7Form.getHeaders()
|
headers: windows7Form.getHeaders()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await sleep(10000)
|
||||||
|
|
||||||
await axios.post(
|
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,
|
macosForm,
|
||||||
{
|
{
|
||||||
headers: macosForm.getHeaders()
|
headers: macosForm.getHeaders()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await sleep(10000)
|
||||||
|
|
||||||
await axios.post(
|
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,
|
linuxForm,
|
||||||
{
|
{
|
||||||
headers: linuxForm.getHeaders()
|
headers: linuxForm.getHeaders()
|
||||||
|
|||||||
@ -31,38 +31,13 @@ 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`
|
">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>`
|
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(
|
await axios.post(`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, {
|
||||||
`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,
|
chat_id,
|
||||||
message_id: messageData.result.message_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'
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user