Files
tg-proxy/clients/powershell/send-telegram.ps1
T
2026-06-26 16:42:07 +05:00

30 lines
731 B
PowerShell

param(
[Parameter(Mandatory=$true)]
[string]$Message,
[Parameter(Mandatory=$false)]
[string]$ServerUrl = "http://localhost:8880",
[Parameter(Mandatory=$true)]
[string]$AppToken
)
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$body = @{
text = $Message
} | ConvertTo-Json -Depth 3
$headers = @{
"Content-Type" = "application/json; charset=utf-8"
"X-App-Token" = $AppToken
}
try {
$response = Invoke-RestMethod -Uri "$ServerUrl/send" -Method Post -Body ([System.Text.Encoding]::UTF8.GetBytes($body)) -Headers $headers
Write-Host "Message sent successfully. Message ID: $($response.message_id)"
exit 0
} catch {
Write-Error "Failed to send message: $_"
exit 1
}