diff --git a/Docs/VoiceControl.md b/Docs/VoiceControl.md index 34fe9ec9..555f34f9 100644 --- a/Docs/VoiceControl.md +++ b/Docs/VoiceControl.md @@ -26,7 +26,7 @@ More supported voice commands are: `Computer, check` [name] ------------------------ -Lets the computer check something, replace [name] by: `Bitcoin rate`, `Christmas`, `CPU`, `date`, `dawn`, `DNS`, `Dogecoin rate`, `drives`, `dusk`, `Earth` (fun), `Ether rate`, `headlines`, `ISS`, `moon phase`, `New Year`, `operating system`, `ping`, `Santa`, `sunrise`, `sunset`, `swap space`, `time`, `time zone`, `up-time`, `VPN`, `weather`, or `zenith`. +Lets the computer check something, replace [name] by: `Bitcoin rate`, `Christmas`, `CPU`, `date`, `dawn`, `DNS`, `Dogecoin rate`, `drives`, `dusk`, `Earth` (fun), `Ether rate`, `headlines`, `ISS`, `midnight`, `moon phase`, `New Year`, `noon`, `operating system`, `ping`, `Santa`, `sunrise`, `sunset`, `swap space`, `tea time`, `time`, `time zone`, `up-time`, `VPN`, `weather`, or `zenith`. `Computer, open` [name] `browser` diff --git a/Scripts/check-midnight.ps1 b/Scripts/check-midnight.ps1 new file mode 100644 index 00000000..cf350d99 --- /dev/null +++ b/Scripts/check-midnight.ps1 @@ -0,0 +1,30 @@ +<# +.SYNOPSIS + Checks the time until Midnight +.DESCRIPTION + This script checks the time until Midnight and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-midnight +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +try { + $Now = [DateTime]::Now + if ($Now.Hour -lt 12) { + $Midnight = Get-Date -Hour 0 -Minute 0 -Second 0 + $Delta = $Now - $Midnight + $Reply = "Midnight was $($Delta.Hours) hours, $($Delta.Minutes) minutes ago." + } else { + $Midnight = Get-Date -Hour 23 -Minute 59 -Second 59 + $Delta = $Midnight - $Now + $Reply = "Midnight is in $($Delta.Hours) hours, $($Delta.Minutes) minutes." + } + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" + exit 1 +} diff --git a/Scripts/check-noon.ps1 b/Scripts/check-noon.ps1 new file mode 100644 index 00000000..65c3e50d --- /dev/null +++ b/Scripts/check-noon.ps1 @@ -0,0 +1,29 @@ +<# +.SYNOPSIS + Checks the time until Noon +.DESCRIPTION + This script checks the time until Noon and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-noon +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +try { + $Now = [DateTime]::Now + $Noon = Get-Date -Hour 12 -Minute 0 -Second 0 + if ($Now -lt $Noon) { + $Delta = $Noon - $Now + $Reply = "Noon is in $($Delta.Hours) hours, $($Delta.Minutes) minutes." + } else { + $Delta = $Now - $Noon + $Reply = "Noon was $($Delta.Hours) hours, $($Delta.Minutes) minutes ago." + } + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" + exit 1 +} diff --git a/Scripts/check-tea-time.ps1 b/Scripts/check-tea-time.ps1 new file mode 100644 index 00000000..22cab581 --- /dev/null +++ b/Scripts/check-tea-time.ps1 @@ -0,0 +1,29 @@ +<# +.SYNOPSIS + Checks the time until Tea time +.DESCRIPTION + This script checks the time until Tea time and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-tea-time +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +try { + $Now = [DateTime]::Now + $TeaTime = Get-Date -Hour 16 -Minute 0 -Second 0 + if ($Now -lt $TeaTime) { + $Delta = $TeaTime - $Now + $Reply = "Tea time is in $($Delta.Hours) hours, $($Delta.Minutes) minutes." + } else { + $Delta = $Now - $TeaTime + $Reply = "Tea time was $($Delta.Hours) hours, $($Delta.Minutes) minutes ago." + } + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" + exit 1 +}