Class: Lita::Handlers::OnewheelDuckDuckGo
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::OnewheelDuckDuckGo
- Defined in:
- lib/lita/handlers/onewheel_duckduckgo.rb
Instance Method Summary collapse
Instance Method Details
#get_result(query) ⇒ Object
18 19 20 |
# File 'lib/lita/handlers/onewheel_duckduckgo.rb', line 18 def get_result(query) result = RestClient.get("http://api.duckduckgo.com/?q=#{query}&format=json") end |
#search(response) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/lita/handlers/onewheel_duckduckgo.rb', line 8 def search(response) query = response.matches[0][0] Lita.logger.debug "Querying for #{query}" result = get_result(query) Lita.logger.debug "Result: #{result}" reply = "DuckDuckGo Result: #{result['Abstract'][0..250]}" Lita.logger.debug "Reply: #{reply}" response.reply reply end |