updated to have apprise as a notification option

This commit is contained in:
2026-04-29 21:14:40 -05:00
parent 327cb22bfd
commit e56b2027cd
2 changed files with 22 additions and 2 deletions
+18 -1
View File
@@ -5,6 +5,9 @@
[string] $qbtUser = $ENV:QBTUSER
[string] $qbtPassword = $ENV:QBTPASSWORD
[string] $notificationWebhookURL = $ENV:NOTIFICATIONWEBHOOKURL
[string] $discordWebhookURL = $ENV:DISCORDWEBHOOKURL
[string] $appriseWebhookURL = $ENV:APPRISEWEBHOOKURL
[string] $appriseWebhookTag = $ENV:APPRISEWEBHOOKTAG
while ($true)
{
@@ -33,8 +36,9 @@ while ($true)
{
$qbtPortChangeBody = 'json={"listen_port":' + $gluetunForwardedPort + '}'
$qbtPortChangeResponse = Invoke-WebRequest -Uri "http://$($qbtHost):$($qbtPort)/api/v2/app/setPreferences" -WebSession $qbtSession -Method POST -Headers $qbtHeaders -Body $qbtPortChangeBody
if ($notificationWebhookURL)
if ($notificationWebhookURL -or $discordWebhookURL)
{
if ($discordWebhookURL) { $notificationWebhookURL = $discordWebhookURL }
$headers = @{
"Content-Type"="application/json"
}
@@ -44,6 +48,19 @@ while ($true)
$json = $body | ConvertTo-Json
Invoke-WebRequest -URI $notificationWebhookURL -Method post -Body $json -Headers $headers
}
elseif ($appriseWebhookURL)
{
$headers = @{
"Content-Type"="application/json"
}
$body = @{
title="QBitTorrent Port Manager"
body="QBitTorrent Listening Port updated to $gluetunForwardedPort"
tags="$appriseWebhookTag"
}
$json = $body | ConvertTo-Json
Invoke-WebRequest -URI $appriseWebhookURL -Method post -Body $json -Headers $headers
}
}
Write-Host "Sleeping for $schedule minutes..."
Start-Sleep ($schedule * 60)