From 6faf07c4cc86fbb4f3c07b3c0ef3136f477e9371 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 27 Jan 2009 02:08:56 +0100 Subject: url plugin: option hash for handle_urls() Turn handle_urls() options (other than the message) into a parameter hash. --- data/rbot/plugins/url.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'data/rbot/plugins') diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb index e75224cf..02255318 100644 --- a/data/rbot/plugins/url.rb +++ b/data/rbot/plugins/url.rb @@ -122,7 +122,12 @@ class UrlPlugin < Plugin return extra.join(", ") if title or not @bot.config['url.titles_only'] end - def handle_urls(m, urls, display_info=@bot.config['url.display_link_info']) + def handle_urls(m, params={}) + opts = { + :display_info => @bot.config['url.display_link_info'] + }.merge params + urls = opts[:urls] + display_info= opts[:display_info] unless (channels = @bot.config['url.only_on_channels']).empty? return unless channels.map { |c| c.downcase }.include?(m.channel.downcase) end @@ -184,7 +189,7 @@ class UrlPlugin < Plugin def info(m, params) escaped = URI.escape(params[:urls].to_s, OUR_UNSAFE) urls = URI.extract(escaped) - Thread.new { handle_urls(m, urls, params[:urls].length) } + Thread.new { handle_urls(m, :urls => urls, :display_info => params[:urls].length) } end def message(m) @@ -193,7 +198,7 @@ class UrlPlugin < Plugin escaped = URI.escape(m.message, OUR_UNSAFE) urls = URI.extract(escaped, ['http', 'https']) return if urls.empty? - Thread.new { handle_urls(m, urls) } + Thread.new { handle_urls(m, :urls => urls) } end def reply_urls(opts={}) -- cgit v1.2.3