fix telegram actions

This commit is contained in:
pompurin404 2024-10-15 14:41:07 +08:00
parent 195ed68152
commit 636a59ec91
No known key found for this signature in database
3 changed files with 31 additions and 42 deletions

View File

@ -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 }}

View File

@ -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()

View File

@ -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`
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`,
{
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`, {
await axios.post(`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, {
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'
})