From fdc9965b306bd3c7d13cb67e79b6204d31212c6c Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sat, 4 Dec 2021 14:02:56 +0100 Subject: [PATCH] Add check-sun.ps1 --- Docs/VoiceControl.md | 2 +- Scripts/check-sun.ps1 | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Scripts/check-sun.ps1 diff --git a/Docs/VoiceControl.md b/Docs/VoiceControl.md index d586ce96..a08d40e6 100644 --- a/Docs/VoiceControl.md +++ b/Docs/VoiceControl.md @@ -25,7 +25,7 @@ More supported voice commands are: `Computer, check` [name] ------------------------ -Lets the computer check something, replace [name] by: `CPU`, `date`, `DNS`, `drives`, `Earth` (fun), `operating system`, `ping`, `swap space`, `time`, `time zone`, `up-time`, `VPN`, or `weather`. +Lets the computer check something, replace [name] by: `CPU`, `date`, `DNS`, `drives`, `Earth` (fun), `operating system`, `ping`, `sun`, `swap space`, `time`, `time zone`, `up-time`, `VPN`, or `weather`. `Computer, open` [name] `browser` diff --git a/Scripts/check-sun.ps1 b/Scripts/check-sun.ps1 new file mode 100644 index 00000000..daf6eecf --- /dev/null +++ b/Scripts/check-sun.ps1 @@ -0,0 +1,22 @@ +<# +.SYNOPSIS + Checks the sun +.DESCRIPTION + This script determines Sun details and answers by text-to-speech (TTS). +.EXAMPLE + PS> ./check-sun +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +try { + $Reply = (Invoke-WebRequest http://wttr.in/?format="Dawn is at %D, sunrise at %S, zenith at %z, sunset at %s, dusk at %d" -UserAgent "curl" -useBasicParsing).Content + "✔️ $Reply" + & "$PSScriptRoot/speak-english.ps1" "$Reply" + exit 0 # success +} catch { + "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" + exit 1 +}