class Lita::Handlers::OnewheelImages
Public Instance Methods
giphy(response)
click to toggle source
# File lib/lita/handlers/onewheel_images.rb, line 34 def giphy(response) unless config.giphy_enabled return end query = 'giphy ' + response.matches[0][0] Lita.logger.debug("Query: #{query}") result = ::OnewheelGoogle::search(query, config.custom_search_engine_id, config.google_api_key, config.safe_search, image = true) if result # Lita.logger.debug("items: #{result['items']}") result['items'].each do |r| if r['mime'] == 'image/gif' if r['link'][/200_s.gif$/] r['link'].gsub! /200_s.gif/, 'giphy.gif' end Lita.logger.debug "response: #{r['link']}" response.reply r['link'] break end end end end
image(response)
click to toggle source
# File lib/lita/handlers/onewheel_images.rb, line 20 def image(response) query = response.matches[0][0] Lita.logger.debug("Config search prefix: #{config.search_prefix.empty?}") unless config.search_prefix.empty? Lita.logger.debug('Adding config prefix.') query = "#{config.search_prefix} #{query}" end Lita.logger.debug "query: #{query}" result = ::OnewheelGoogle::search(query, config.custom_search_engine_id, config.google_api_key, config.safe_search, image = true) Lita.logger.debug "response: #{result['items'][0]['link']}" response.reply result['items'][0]['link'] end