diff --git a/Start-DoneTickNotifier.ps1 b/Start-DoneTickNotifier.ps1 index e5623d4..c39a512 100644 --- a/Start-DoneTickNotifier.ps1 +++ b/Start-DoneTickNotifier.ps1 @@ -3,7 +3,7 @@ [string] $dtAPIKey = $ENV:DONETICKAPIKEY [string] $appriseWebhookURL = $ENV:APPRISEWEBHOOKURL [string] $appriseWebhookTag = $ENV:APPRISEWEBHOOKTAG -[int[]] $notificationTimes = $ENV:NOTIFICATIONTIMES | Sort-Object +[int[]] $notificationTimes = $ENV:NOTIFICATIONTIMES -split "," function Send-Notification @@ -51,6 +51,10 @@ function Get-Chores } } +if (-not $notificationTimes) { $notificationTimes = @(8) } +else { $notificationTimes = $notificationTimes | Sort-Object } +Write-Host "Notification times: $notificationTimes" + while ($true) { $today = (Get-Date "23:59:59") $chores = Get-Chores @@ -122,8 +126,9 @@ while ($true) { } if ($nextNotificationTomorrow) { + $time = $notificationTimes[0] Write-Host "Next notification time is $time`:00" - $diff = 24 - $now.Hour + $notificationTimes[0] + $diff = 24 - $now.Hour + $time $sleepTime = $diff * 60 * 60 # hours * mins * seconds Write-Host "Sleeping for $sleepTime seconds" Start-Sleep -Seconds $sleepTime