diff --git a/Gemfile b/Gemfile index 312f577..879a28a 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,5 @@ source "https://rubygems.org" gem 'alexa_skills_ruby' gem 'sinatra' +gem 'nokogiri' # gem "rails" diff --git a/Gemfile.lock b/Gemfile.lock index 732167e..0120699 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,8 +11,11 @@ GEM multi_json (~> 1.0) concurrent-ruby (1.0.2) i18n (0.7.0) + mini_portile2 (2.0.0) minitest (5.10.1) multi_json (1.12.1) + nokogiri (1.6.7.2-x64-mingw32) + mini_portile2 (~> 2.0.0.rc2) rack (1.6.5) rack-protection (1.5.3) rack @@ -30,6 +33,7 @@ PLATFORMS DEPENDENCIES alexa_skills_ruby + nokogiri sinatra BUNDLED WITH diff --git a/app.rb b/app.rb index 34b7f6c..541bc33 100644 --- a/app.rb +++ b/app.rb @@ -1,16 +1,26 @@ require 'sinatra' require 'alexa_skills_ruby' +require 'rubygems' +require 'nokogiri' +require 'open-uri' class CustomHandler < AlexaSkillsRuby::Handler on_intent("GetDeveloperExcuse") do - response.set_output_speech_text("Developer Excuses yo") + response.set_output_speech_text(get_excuse) end end get '/livecheck' do "hello" end + +get '/excuse' do + get_excuse +end + + + post '/' do content_type :json @@ -23,4 +33,9 @@ post '/' do 403 end -end \ No newline at end of file +end + +def get_excuse + page = Nokogiri::HTML(open("http://programmingexcuses.com/")) + page.css("a").text +end