]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/freshmeat.rb
url plugin: customizable max amount of data to retrieve to look for a title. return...
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / freshmeat.rb
index 20fa724800fb228a693e463608f1eef3dc230e71..c8f529cbcf73c514899a0b5d8794ca7f1a695453 100644 (file)
@@ -12,7 +12,7 @@ class FreshmeatPlugin < Plugin
     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)}"))
+      xml = @bot.httputil.get_cached(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
@@ -58,16 +58,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(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
+        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