Add check-midnight.ps1, check-noon.ps1, and check-tea-time.ps1

This commit is contained in:
Markus Fleschutz 2021-12-07 17:03:58 +01:00
parent 6fb9fe787a
commit 13aacff361
4 changed files with 89 additions and 1 deletions

View File

@ -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`

View File

@ -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
}

29
Scripts/check-noon.ps1 Normal file
View File

@ -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
}

View File

@ -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
}