Class: Lita::Handlers::OnewheelFilmplot

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

Instance Method Summary collapse

Instance Method Details

#get_plot(response) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lita/handlers/onewheel_filmplot.rb', line 19

def get_plot(response)
  movie_slug = response.matches[0][0].gsub ' ', '_'
  begin
    r = RestClient.get("https://www.rottentomatoes.com/m/#{movie_slug}")
    noko_doc = Nokogiri::HTML(r)
    node = noko_doc.css('div#movieSynopsis')
    response.reply node.text.strip
  rescue RestClient::ResourceNotFound => e
    response.reply "#{movie_slug} not found."
  end
end