enable looping so the script can handle scheduling
Security / security (push) Successful in 1m7s

This commit is contained in:
2026-05-13 21:09:52 -05:00
parent 90a2805339
commit 998f639a55
2 changed files with 59 additions and 40 deletions
+18
View File
@@ -3,6 +3,7 @@
[string] $dtAPIKey = $ENV:DONETICKAPIKEY
[string] $appriseWebhookURL = $ENV:APPRISEWEBHOOKURL
[string] $appriseWebhookTag = $ENV:APPRISEWEBHOOKTAG
[int[]] $notificationTimes = $ENV:NOTIFICATIONTIMES | Sort-Object
function Send-Notification
@@ -50,6 +51,7 @@ function Get-Chores
}
}
while ($true) {
$today = (Get-Date "23:59:59")
$chores = Get-Chores
@@ -101,3 +103,19 @@ if ($todaysTasks.Count -ne 0)
}
Send-Notification -title "TODAY'S TASKS" -content $content
}
Write-Host "Finding next notification time..."
foreach($time in $notificationTimes)
{
$now = Get-Date
$diff = $now.Hour - $time
if ($diff -lt 0) # next notification time
{
Write-Host "Next notification time is $time`:00"
$sleepTime = ($diff * -1) * 60
Write-Host "Sleeping for $sleepTime seconds"
Start-Sleep -Seconds $sleepTime
continue # leave loop
}
}
}
+1
View File
@@ -10,3 +10,4 @@ services:
- DONETICKAPIKEY=adminpass # donetick API key
- APPRISEWEBHOOKURL=https://apprisehost/notify/config # apprise notification url
- APPRISEWEBHOOKTAG=all # apprise notification tag
- NOTIFICATIONTIMES=8,12,17 # hours when notifications will be sent