Skip to content

Instantly share code, notes, and snippets.

@benjaminlukeclark
Forked from johnallers/catfacts.ps1
Last active August 18, 2018 12:17
Show Gist options
  • Save benjaminlukeclark/5abcab086f0c248044fa9686f362f395 to your computer and use it in GitHub Desktop.
Save benjaminlukeclark/5abcab086f0c248044fa9686f362f395 to your computer and use it in GitHub Desktop.
Sadly the original API used for this appears to have been deprecated by Google.
But I found another! Hazur! Cheezeburgers for all.
Full credit to the original post for the absolutely amazing idea and coming up with the logic, I've just replaced
the API used to be http://www.catfact.info/
#Run this every 1/2 hour and in an 8 hour work day there will be approximately 3 times per day that your victim hears a cat fact
if ((Get-Random -Maximum 10000) -lt 1875) {
Add-Type -AssemblyName System.Speech
$SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$Random = Get-Random -Maximum 200
$CatFact = (ConvertFrom-Json (Invoke-WebRequest -Uri http://www.catfact.info/api/v1/facts.json?per_page=200)).Facts[$Random]
$SpeechSynth.Speak("did you know?")
$SpeechSynth.Speak($CatFact.details)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment