Permalink
Browse files

Now get random comics from xkcd

  • Loading branch information...
1 parent f2897b5 commit 06958259ffe8c65d82b5eb577c4381309ed3e352 @hemanth committed Nov 4, 2010
Showing with 10 additions and 0 deletions.
  1. +10 −0 rgbot.rb
View
@@ -29,6 +29,16 @@ def goog(msg)
self.deliver(msg,JSON.parse(Net::HTTP.get_response(URI.parse(gurl)).body)['responseData']['results'][0]['url'])
end
+ def xkcd(msg)
+ uri = URI.parse 'http://dynamic.xkcd.com/random/comic/'
+ req = Net::HTTP::Get.new(uri.request_uri)
+ http = Net::HTTP.new(uri.host)
+ res = http.start { |server|
+ server.request(req)
+ }
+ self.deliver(msg,res["location"]+ " Enjoy it!")
+ end
+
def main
while (true) do
@jabber.received_messages do |msg|

0 comments on commit 0695825

Please sign in to comment.