This repository has been archived by the owner on Feb 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pompurin404
committed
Oct 13, 2024
1 parent
36261a6
commit 7dc153d
Showing
4 changed files
with
240 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
import fs from 'fs' | ||
import axios from 'axios' | ||
import path from 'path' | ||
import FormData from 'form-data' | ||
|
||
const CHAT_ID = '@mihomo_party_group' | ||
const GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE | ||
const pkg = fs.readFileSync('package.json', 'utf-8') | ||
const { version } = JSON.parse(pkg) | ||
|
||
const linuxFiles = [ | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-linux-${version}-aarch64.rpm | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-linux-${version}-arm64.deb | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-linux-${version}-x86_64.rpm | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-linux-${version}-amd64.deb | ||
` | ||
) | ||
] | ||
|
||
const macosFiles = [ | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-macos-${version}-arm64.dmg | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-macos-${version}-x64.dmg | ||
` | ||
) | ||
] | ||
|
||
const windowsFiles = [ | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-windows-${version}-x64-setup.exe | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-windows-${version}-x64-portable.7z | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-windows-${version}-ia32-setup.exe | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-windows-${version}-ia32-portable.7z | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-windows-${version}-arm64-setup.exe | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-windows-${version}-arm64-portable.7z | ||
` | ||
) | ||
] | ||
|
||
const windows7Files = [ | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-win7-${version}-x64-setup.exe | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-win7-${version}-x64-portable.7z | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-win7-${version}-ia32-setup.exe | ||
` | ||
), | ||
path.join( | ||
GITHUB_WORKSPACE, | ||
`mihomo-party-win7-${version}-ia32-portable.7z | ||
` | ||
) | ||
] | ||
|
||
const windowsMedia = windowsFiles.map((_, index) => ({ | ||
type: 'document', | ||
media: `attach://file${index}` | ||
})) | ||
const windowsForm = new FormData() | ||
windowsForm.append('chat_id', CHAT_ID) | ||
windowsForm.append('media', JSON.stringify(windowsMedia)) | ||
windowsFiles.forEach((file, index) => { | ||
windowsForm.append(`file${index}`, fs.createReadStream(file)) | ||
}) | ||
|
||
const windows7Media = windows7Files.map((_, index) => ({ | ||
type: 'document', | ||
media: `attach://file${index}` | ||
})) | ||
const windows7Form = new FormData() | ||
windows7Form.append('chat_id', CHAT_ID) | ||
windows7Form.append('media', JSON.stringify(windows7Media)) | ||
windows7Files.forEach((file, index) => { | ||
windows7Form.append(`file${index}`, fs.createReadStream(file)) | ||
}) | ||
|
||
const linuxMedia = linuxFiles.map((_, index) => ({ | ||
type: 'document', | ||
media: `attach://file${index}` | ||
})) | ||
const linuxForm = new FormData() | ||
linuxForm.append('chat_id', CHAT_ID) | ||
linuxForm.append('media', JSON.stringify(linuxMedia)) | ||
linuxFiles.forEach((file, index) => { | ||
linuxForm.append(`file${index}`, fs.createReadStream(file)) | ||
}) | ||
|
||
const macosMedia = macosFiles.map((_, index) => ({ | ||
type: 'document', | ||
media: `attach://file${index}` | ||
})) | ||
const macosForm = new FormData() | ||
macosForm.append('chat_id', CHAT_ID) | ||
macosForm.append('media', JSON.stringify(macosMedia)) | ||
macosFiles.forEach((file, index) => { | ||
macosForm.append(`file${index}`, fs.createReadStream(file)) | ||
}) | ||
|
||
await axios.post(`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, { | ||
chat_id: CHAT_ID, | ||
text: `Windows10/11 测试版` | ||
}) | ||
await axios | ||
.post(`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`, windowsForm, { | ||
headers: windowsForm.getHeaders() | ||
}) | ||
.then((response) => { | ||
console.log('Success:', response.data) | ||
}) | ||
.catch((error) => { | ||
console.error('Error:', error.response ? error.response.data : error.message) | ||
}) | ||
|
||
await axios.post(`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, { | ||
chat_id: CHAT_ID, | ||
text: `Windows7/8 测试版` | ||
}) | ||
await axios | ||
.post(`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`, windows7Form, { | ||
headers: windows7Form.getHeaders() | ||
}) | ||
.then((response) => { | ||
console.log('Success:', response.data) | ||
}) | ||
.catch((error) => { | ||
console.error('Error:', error.response ? error.response.data : error.message) | ||
}) | ||
|
||
await axios.post(`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, { | ||
chat_id: CHAT_ID, | ||
text: `macOS 测试版` | ||
}) | ||
await axios | ||
.post(`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`, macosForm, { | ||
headers: macosForm.getHeaders() | ||
}) | ||
.then((response) => { | ||
console.log('Success:', response.data) | ||
}) | ||
.catch((error) => { | ||
console.error('Error:', error.response ? error.response.data : error.message) | ||
}) | ||
|
||
await axios.post(`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, { | ||
chat_id: CHAT_ID, | ||
text: `Linux 测试版` | ||
}) | ||
await axios | ||
.post(`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`, linuxForm, { | ||
headers: linuxForm.getHeaders() | ||
}) | ||
.then((response) => { | ||
console.log('Success:', response.data) | ||
}) | ||
.catch((error) => { | ||
console.error('Error:', error.response ? error.response.data : error.message) | ||
}) |