Last active
July 13, 2025 22:37
-
-
Save SQLDBAWithABeard/3fb42ad44987be7cbb4c5dba6cc65620 to your computer and use it in GitHub Desktop.
insult generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I am serious. And don't call me Shirley. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-Insult { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter()] | |
| [switch]$Speak = $true | |
| ) | |
| Add-Type -AssemblyName System.Speech | |
| $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer | |
| $voice = $synth.GetInstalledVoices().VoiceInfo.Name | |
| $synth.SelectVoice($voice[0]) | |
| $uri = 'https://insult.mattbas.org/api/insult' | |
| try { | |
| $response = Invoke-RestMethod -Uri $uri -Method Get | |
| $response | |
| } catch { | |
| # Write-Error "Failed to retrieve insult: $_" | |
| # Optionally, you can return a default message or handle the error differently | |
| return "I couldn't think of an insult right now." | |
| } | |
| if($Speak) { | |
| $synth.Speak($response) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment