Class: Lita::Handlers::Pun
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::Pun
- Defined in:
- lib/lita/handlers/pun.rb
Instance Method Summary collapse
Instance Method Details
#build_pun_response(url) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lita/handlers/pun.rb', line 28 def build_pun_response(url) #Build the HTTP request uri = URI(url) source = Net::HTTP.get(uri) #Parse out the actual pun text html_doc = Nokogiri::HTML(source) pun = html_doc.css("div[class='dropshadow1']").css("p").text return pun end |
#pun(response) ⇒ Object
16 17 18 19 20 |
# File 'lib/lita/handlers/pun.rb', line 16 def pun(response) #Get a random pun pun = build_pun_response("http://www.punoftheday.com/cgi-bin/randompun.pl") response.reply(pun) end |
#pun_of_the_day(response) ⇒ Object
22 23 24 25 26 |
# File 'lib/lita/handlers/pun.rb', line 22 def pun_of_the_day(response) #Get the pun of the day pun = build_pun_response("http://www.punoftheday.com/") response.reply(pun) end |