]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/slashdot.rb
*** (httputil) major rework, new caching implementation, unified request
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / slashdot.rb
index 1a70de08c4ceb8091a1c6e4b8ee1a19384b3ab70..fa1338bdcc8d6f75af330e9bbe31e309e8bf12b1 100644 (file)
@@ -12,7 +12,7 @@ class SlashdotPlugin < Plugin
    search = params[:search].to_s
 
     begin
-      xml = @bot.httputil.get(URI.parse("http://slashdot.org/search.pl?content_type=rss&query=#{URI.escape(search)}"))
+      xml = @bot.httputil.get("http://slashdot.org/search.pl?content_type=rss&query=#{URI.escape(search)}")
     rescue URI::InvalidURIError, URI::BadURIError => e
       m.reply "illegal search string #{search}"
       return
@@ -21,11 +21,11 @@ class SlashdotPlugin < Plugin
       m.reply "search for #{search} failed"
       return
     end
-    puts xml.inspect
+    debug xml.inspect
     begin
       doc = Document.new xml
     rescue REXML::ParseException => e
-      puts e
+      warning e.inspect
       m.reply "couldn't parse output XML: #{e.class}"
       return
     end
@@ -33,7 +33,7 @@ class SlashdotPlugin < Plugin
       m.reply "search for #{search} failed"
       return
     end
-    puts doc.inspect
+    debug doc.inspect
     max = 8 if max > 8
     done = 0
     doc.elements.each("*/item") {|e|
@@ -50,10 +50,10 @@ class SlashdotPlugin < Plugin
   end
   
   def slashdot(m, params)
-    puts params.inspect
+    debug params.inspect
     max = params[:limit].to_i
-    puts "max is #{max}"
-    xml = @bot.httputil.get(URI.parse("http://slashdot.org/slashdot.xml"))
+    debug "max is #{max}"
+    xml = @bot.httputil.get('http://slashdot.org/slashdot.xml')
     unless xml
       m.reply "slashdot news parse failed"
       return