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 a4aa3cf
Showing
4 changed files
with
121 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,88 @@ | ||
import fs from 'fs' | ||
import axios from 'axios' | ||
import path from 'path' | ||
import FormData from 'form-data' | ||
import { fileURLToPath } from 'url' | ||
|
||
const CHAT_ID = '@mihomo_party_group' | ||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = path.dirname(__filename) | ||
const pkg = fs.readFileSync('package.json', 'utf-8') | ||
const { version } = JSON.parse(pkg) | ||
|
||
const files = [ | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-linux-${version}-aarch64.rpm | ||
` | ||
), | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-linux-${version}-arm64.deb | ||
` | ||
), | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-linux-${version}-x86_64.rpm | ||
` | ||
), | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-linux-${version}-amd64.deb | ||
` | ||
), | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-macos-${version}-arm64.dmg | ||
` | ||
), | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-macos-${version}-x64.dmg | ||
` | ||
), | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-windows-${version}-x64-setup.exe | ||
` | ||
), | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-windows-${version}-x64-portable.7z | ||
` | ||
), | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-win7-${version}-x64-setup.exe | ||
` | ||
), | ||
path.join( | ||
__dirname, | ||
`../mihomo-party-win7-${version}-x64-portable.7z | ||
` | ||
) | ||
] | ||
|
||
const media = files.map((_, index) => ({ | ||
type: 'document', | ||
media: `attach://file${index}` | ||
})) | ||
|
||
const form = new FormData() | ||
form.append('chat_id', CHAT_ID) | ||
form.append('media', JSON.stringify(media)) | ||
|
||
files.forEach((file, index) => { | ||
form.append(`file${index}`, fs.createReadStream(file)) | ||
}) | ||
|
||
axios | ||
.post(`http://127.0.0.1:8088/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`, form, { | ||
headers: form.getHeaders() | ||
}) | ||
.then((response) => { | ||
console.log('Success:', response.data) | ||
}) | ||
.catch((error) => { | ||
console.error('Error:', error.response ? error.response.data : error.message) | ||
}) |