"slashdot search <string> [<max>=4] => search slashdot for <string>, slashdot [<max>=4] => return up to <max> slashdot headlines (use negative max to return that many headlines, but all on one line.)"
end
def help(plugin, topic="")
"slashdot search <string> [<max>=4] => search slashdot for <string>, slashdot [<max>=4] => return up to <max> slashdot headlines (use negative max to return that many headlines, but all on one line.)"
end
- def privmsg(m)
- if m.params && m.params =~ /^search\s+(.*)\s+(\d+)$/
- search = $1
- limit = $2.to_i
- search_slashdot m, search, limit
- elsif m.params && m.params =~ /^search\s+(.*)$/
- search = $1
- search_slashdot m, search
- elsif m.params && m.params =~ /^([-\d]+)$/
- limit = $1.to_i
- slashdot m, limit
- else
- slashdot m
- end
- end
- def search_slashdot(m, search, max=4)
+ def search_slashdot(m, params)
+ max = params[:limit].to_i
+ search = params[:search].to_s
+
begin
xml = @bot.httputil.get(URI.parse("http://slashdot.org/search.pl?content_type=rss&query=#{URI.escape(search)}"))
rescue URI::InvalidURIError, URI::BadURIError => e
begin
xml = @bot.httputil.get(URI.parse("http://slashdot.org/search.pl?content_type=rss&query=#{URI.escape(search)}"))
rescue URI::InvalidURIError, URI::BadURIError => e