ok excuses work

This commit is contained in:
Tommy Parnell
2016-12-01 21:26:20 -05:00
parent d9ebb5a706
commit 895408c86a
3 changed files with 22 additions and 2 deletions

View File

@@ -2,4 +2,5 @@
source "https://rubygems.org" source "https://rubygems.org"
gem 'alexa_skills_ruby' gem 'alexa_skills_ruby'
gem 'sinatra' gem 'sinatra'
gem 'nokogiri'
# gem "rails" # gem "rails"

View File

@@ -11,8 +11,11 @@ GEM
multi_json (~> 1.0) multi_json (~> 1.0)
concurrent-ruby (1.0.2) concurrent-ruby (1.0.2)
i18n (0.7.0) i18n (0.7.0)
mini_portile2 (2.0.0)
minitest (5.10.1) minitest (5.10.1)
multi_json (1.12.1) multi_json (1.12.1)
nokogiri (1.6.7.2-x64-mingw32)
mini_portile2 (~> 2.0.0.rc2)
rack (1.6.5) rack (1.6.5)
rack-protection (1.5.3) rack-protection (1.5.3)
rack rack
@@ -30,6 +33,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
alexa_skills_ruby alexa_skills_ruby
nokogiri
sinatra sinatra
BUNDLED WITH BUNDLED WITH

19
app.rb
View File

@@ -1,16 +1,26 @@
require 'sinatra' require 'sinatra'
require 'alexa_skills_ruby' require 'alexa_skills_ruby'
require 'rubygems'
require 'nokogiri'
require 'open-uri'
class CustomHandler < AlexaSkillsRuby::Handler class CustomHandler < AlexaSkillsRuby::Handler
on_intent("GetDeveloperExcuse") do on_intent("GetDeveloperExcuse") do
response.set_output_speech_text("Developer Excuses yo") response.set_output_speech_text(get_excuse)
end end
end end
get '/livecheck' do get '/livecheck' do
"hello" "hello"
end end
get '/excuse' do
get_excuse
end
post '/' do post '/' do
content_type :json content_type :json
@@ -23,4 +33,9 @@ post '/' do
403 403
end end
end end
def get_excuse
page = Nokogiri::HTML(open("http://programmingexcuses.com/"))
page.css("a").text
end