From 6139b89ff92dd89e206f5073ccdde29698d2eacd Mon Sep 17 00:00:00 2001 From: Tom Gilbert Date: Tue, 26 Jul 2005 22:49:47 +0000 Subject: [PATCH] use new maps api --- rbot/plugins/freshmeat.rb | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/rbot/plugins/freshmeat.rb b/rbot/plugins/freshmeat.rb index 420c1bcb..20fa7248 100644 --- a/rbot/plugins/freshmeat.rb +++ b/rbot/plugins/freshmeat.rb @@ -4,25 +4,12 @@ require 'uri/common' class FreshmeatPlugin < Plugin include REXML def help(plugin, topic="") - "freshmeat search [=4] => search freshmeat for , freshmeat [=4] => return up to freshmeat headlines" - end - def privmsg(m) - if m.params && m.params =~ /^search\s+(.*)\s+(\d+)$/ - search = $1 - limit = $2.to_i - search_freshmeat m, search, limit - elsif m.params && m.params =~ /^search\s+(.*)$/ - search = $1 - search_freshmeat m, search - elsif m.params && m.params =~ /^(\d+)$/ - limit = $1.to_i - freshmeat m, limit - else - freshmeat m - end + "freshmeat search [=4] => search freshmeat for , freshmeat [=4] => return up to freshmeat headlines" end - def search_freshmeat(m, search, max=4) + def search_freshmeat(m, params) + 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)}")) @@ -68,7 +55,8 @@ class FreshmeatPlugin < Plugin } end - def freshmeat(m, max=4) + 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 @@ -104,4 +92,7 @@ class FreshmeatPlugin < Plugin end end plugin = FreshmeatPlugin.new -plugin.register("freshmeat") +plugin.map 'freshmeat search :limit *search', :action => 'search_freshmeat', + :defaults => {:limit => 4}, :requirements => {:limit => /^\d+$/} +plugin.map 'freshmeat :limit', :defaults => {:limit => 4}, + :requirements => {:limit => /^\d+$/} -- 2.39.5