2021-12-05 11:47:03 +01:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Checks the Bitcoin rate
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
This script queries the current Bitcoin exchange rates and answers by text-to-speech (TTS).
|
|
|
|
|
.EXAMPLE
|
2021-12-07 07:15:39 +01:00
|
|
|
|
PS> ./check-bitcoin-rate
|
2021-12-05 11:47:03 +01:00
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz · License: CC0
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$Rates = (Invoke-WebRequest -uri "https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,EUR" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
2021-12-06 17:00:49 +01:00
|
|
|
|
|
|
|
|
|
& "$PSScriptRoot/give-reply.ps1" "Bitcoin is currently at $($Rates.USD) US$ and $($Rates.EUR) Euro."
|
2021-12-05 11:47:03 +01:00
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
|
|
|
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|