Class: Lita::Handlers::Urban

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/urban.rb

Instance Method Summary collapse

Instance Method Details

#define_word(response) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/lita/handlers/urban.rb', line 8

def define_word(response)
  term = response.matches[0][1]
  http_response = http.get("http://api.urbandictionary.com/v0/define", term: term)
  entry = MultiJson.load(http_response.body)["list"].first
  if entry
    response.reply(entry["definition"])
  else
    response.reply("No definition found for #{term}")
  end
end