class Lita::Handlers::OnewheelYoutube
Public Instance Methods
search(response)
click to toggle source
# File lib/lita/handlers/onewheel_youtube.rb, line 14 def search(response) query = response.matches[0][0] result = ::OnewheelGoogle::search('site:youtube.com ' + query, config.custom_search_engine_id, config.google_api_key, config.safe_search) first_item = result['items'][0] video_id = first_item['pagemap']['videoobject'][0]['videoid'] video_link = "http://y2u.be/#{video_id}" reply = "#{video_link} #{first_item['title']}".sub(/\n/, ' ')[0..500] response.reply reply end