]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/freshmeat.rb
reaction plugin: no more :stuff, but :before and :after for the pre and postmatch...
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / freshmeat.rb
index 20fa724800fb228a693e463608f1eef3dc230e71..49e73e0d2785b447ecef4237240c048765c548db 100644 (file)
@@ -1,5 +1,4 @@
 require 'rexml/document'
-require 'uri/common'
 
 class FreshmeatPlugin < Plugin
   include REXML
@@ -11,12 +10,7 @@ class FreshmeatPlugin < Plugin
     max = params[:limit].to_i
     search = params[:search].to_s
     max = 8 if max > 8
-    begin
-      xml = @bot.httputil.get(URI.parse("http://freshmeat.net/search-xml/?orderby=locate_projectname_full_DESC&q=#{URI.escape(search)}"))
-    rescue URI::InvalidURIError, URI::BadURIError => e
-      m.reply "illegal search string #{search}"
-      return
-    end
+    xml = @bot.httputil.get("http://freshmeat.net/search-xml/?orderby=locate_projectname_full_DESC&q=#{CGI.escape(search)}")
     unless xml
       m.reply "search for #{search} failed"
       return
@@ -58,16 +52,22 @@ class FreshmeatPlugin < Plugin
   def freshmeat(m, params)
     max = params[:limit].to_i
     max = 8 if max > 8
-    xml = @bot.httputil.get(URI.parse("http://images.feedstermedia.com/feedcache/ostg/freshmeat/fm-releases-global.xml"))
-    unless xml
-      m.reply "freshmeat news parse failed"
-      return
-    end
-    doc = Document.new xml
-    unless doc
+    begin
+      xml = @bot.httputil.get('http://images.feedstermedia.com/feedcache/ostg/freshmeat/fm-releases-global.xml')
+      unless xml
+        m.reply "freshmeat news parse failed"
+        return
+      end
+      doc = Document.new xml
+      unless doc
+        m.reply "freshmeat news parse failed"
+        return
+      end
+    rescue
       m.reply "freshmeat news parse failed"
       return
     end
+
     matches = Array.new
     max_width = 60
     title_width = 0