Null-DRM-Official/scripts/notify-telegram.ps1
404errordeveloper ac8701b5a6
All checks were successful
release / build-and-upload (push) Successful in 6m20s
modules-release / build-and-upload (push) Successful in 4m51s
streamd: optional keys, per-stream proxy, auto deps; agent module.yaml sync; RTE AutoPlay; Telegram release announces
- streamd: MPD-only start, proxy field, ffmpeg/NRE/mp4decrypt auto-install
- GET/PUT /api/modules for module.yaml sync; agent sync_modules
- RTE Live-tab AutoPlay fixes; modules zip named bbc/rte/tg4.zip
- Telegram notify scripts wired into Forgejo release workflows
2026-10-09 00:17:23 +02:00

95 lines
2.7 KiB
PowerShell

# Post a release announce to Telegram.
#
# Required env:
# TELEGRAM_BOT_TOKEN BotFather token (never commit)
# TELEGRAM_CHAT_ID e.g. -1003721978702
#
# Usage:
# $env:TELEGRAM_BOT_TOKEN="…"; $env:TELEGRAM_CHAT_ID="-1003721978702"
# .\scripts\notify-telegram.ps1 -Tag v0.1.2
# .\scripts\notify-telegram.ps1 -Tag modules-v0.1.2 -DryRun
param(
[string]$Tag = "",
[string]$Kind = "auto", # auto | host | modules
[string]$Title = "",
[string]$Body = "",
[string]$ReleaseUrl = "",
[string]$RepoUrl = "https://git.nulldrm.com/nulldrm/Null-DRM-Official",
[switch]$DryRun
)
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
if (-not $Tag) { $Tag = $env:RELEASE_TAG }
if (-not $Tag) {
try { $Tag = (git -C $Root describe --tags --exact-match 2>$null) } catch { }
}
if (-not $Tag) {
try { $Tag = (git -C $Root describe --tags --always 2>$null) } catch { }
}
if (-not $Tag) { throw "usage: notify-telegram.ps1 -Tag v0.1.2" }
$Token = $env:TELEGRAM_BOT_TOKEN
$Chat = $env:TELEGRAM_CHAT_ID
if (-not $Token -or -not $Chat) {
throw "TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID are required"
}
if ($Kind -eq "auto") {
if ($Tag -like "modules-v*") { $Kind = "modules" } else { $Kind = "host" }
}
if (-not $ReleaseUrl) {
if ($env:RELEASE_URL) { $ReleaseUrl = $env:RELEASE_URL }
else { $ReleaseUrl = "$RepoUrl/releases/tag/$Tag" }
}
if (-not $Title) {
if ($env:RELEASE_TITLE) { $Title = $env:RELEASE_TITLE }
elseif ($Kind -eq "modules") { $Title = "Null DRM $Tag" }
else { $Title = "Null DRM $Tag" }
}
if (-not $Body) {
if ($env:RELEASE_BODY) {
$Body = $env:RELEASE_BODY
} elseif ($Kind -eq "modules") {
$Body = @"
<b>$Title</b>
Provider module zips: <code>bbc.zip</code>, <code>rte.zip</code>, <code>tg4.zip</code>
Unpack each into <code>modules/&lt;name&gt;/</code> and edit <code>module.yaml</code> for secrets.
<a href="$ReleaseUrl">Download $Tag</a>
"@
} else {
$Body = @"
<b>$Title</b>
Host CLI (<code>drm</code>) + on-device MITM (<code>proxy-android-arm64</code>).
<a href="$ReleaseUrl">Download $Tag</a>
"@
}
}
if ($DryRun) {
Write-Host "DRY_RUN chat=$Chat tag=$Tag kind=$Kind"
Write-Host "----"
Write-Host $Body
return
}
Write-Host "[*] Telegram notify → chat $Chat ($Tag)"
$uri = "https://api.telegram.org/bot$Token/sendMessage"
$form = @{
chat_id = $Chat
text = $Body
parse_mode = "HTML"
disable_web_page_preview = "false"
}
$resp = Invoke-RestMethod -Method Post -Uri $uri -Body $form
if (-not $resp.ok) {
throw "Telegram API error: $($resp | ConvertTo-Json -Compress)"
}
Write-Host "[+] Telegram announce sent for $Tag (message_id=$($resp.result.message_id))"