Sha256: 3c0f580ba92c24586bee13bfda115deac29ba1b7887fddc3fb8419ff53e29a42
Contents?: true
Size: 663 Bytes
Versions: 1
Compression:
Stored size: 663 Bytes
Contents
require "lita" module Lita module Handlers class Catfacts < Handler route %r{catfact(|s)}i, :catfacts, command: true, help: { "catfacts" => "Returns a random fact about cats." } def catfacts(response) resp = http.get('http://catfacts-api.appspot.com/api/facts?number=1') raise 'RequestFail' unless resp.status == 200 obj = MultiJson.load(resp.body) raise 'ApiError' unless obj['success'] == "true" response.reply obj['facts'][0] rescue response.reply "Sorry, I was unable to find any cool facts about cats." end end Lita.register_handler(Catfacts) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-catfacts-0.0.1 | lib/lita/handlers/catfacts.rb |