lib/waylon/skills/jokes.rb in waylon-jokes-0.1.0 vs lib/waylon/skills/jokes.rb in waylon-jokes-0.2.0

- old
+ new

@@ -13,15 +13,27 @@ } ) def tell_a_joke conn = Faraday.new(headers: { accept: "application/json" }) do |f| - f.request :retry f.response :json end response = conn.get("https://icanhazdadjoke.com/") reply(response.body["joke"]) + rescue Faraday::Error + reply(fallback) + end + + def fallback + [ + "I was addicted to the hokey pokey…but I turned myself around.", + "What invention allows us to see through walls? Windows.", + "The past, the present, and the future walked into a bar. It was tense.", + "What's the least-spoken language in the world? Sign language.", + "Why do cows wear bells? Because their horns don't work.", + "Police arrested a bottle of water because it was wanted in three different states: solid, liquid, and gas." + ].sample end end end end