summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/url.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-10 12:37:36 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-10 12:37:36 +0000
commitcbdd5e3f0330ebb1433223424adba6af52ea52d5 (patch)
treee0a8ab5016c5e6a2e0be4e1d087968444105bd2e /data/rbot/plugins/url.rb
parent867bef6674fbccfc8a8aed4f96d7a52b22a60791 (diff)
url plugin: add 'urls info *urls' command to force link info retrieval
Diffstat (limited to 'data/rbot/plugins/url.rb')
-rw-r--r--data/rbot/plugins/url.rb35
1 files changed, 26 insertions, 9 deletions
diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb
index 81852103..16b2e28e 100644
--- a/data/rbot/plugins/url.rb
+++ b/data/rbot/plugins/url.rb
@@ -152,22 +152,21 @@ class UrlPlugin < Plugin
end
end
- def listen(m)
- return unless m.kind_of?(PrivMessage)
- return if m.address?
-
- escaped = URI.escape(m.message, OUR_UNSAFE)
- urls = URI.extract(escaped)
+ def handle_urls(m, urls, display_info=@bot.config['url.display_link_info'])
return if urls.empty?
debug "found urls #{urls.inspect}"
- list = @registry[m.target]
+ if m.public?
+ list = @registry[m.target]
+ else
+ list = nil
+ end
urls_displayed = 0
urls.each { |urlstr|
debug "working on #{urlstr}"
next unless urlstr =~ /^https?:/
title = nil
- debug "display link info: #{@bot.config['url.display_link_info']}"
- if @bot.config['url.display_link_info'] > urls_displayed
+ debug "display link info: #{display_info}"
+ if display_info > urls_displayed
urls_displayed += 1
Thread.start do
debug "Getting title for #{urlstr}..."
@@ -185,6 +184,8 @@ class UrlPlugin < Plugin
end
end
+ next unless list
+
# check to see if this url is already listed
next if list.find {|u| u.url == urlstr }
@@ -200,6 +201,21 @@ class UrlPlugin < Plugin
@registry[m.target] = list
end
+ def info(m, params)
+ escaped = URI.escape(params[:urls].to_s, OUR_UNSAFE)
+ urls = URI.extract(escaped)
+ handle_urls(m, urls, params[:urls].length)
+ end
+
+ def listen(m)
+ return unless m.kind_of?(PrivMessage)
+ return if m.address?
+
+ escaped = URI.escape(m.message, OUR_UNSAFE)
+ urls = URI.extract(escaped)
+ handle_urls(m, urls)
+ end
+
def reply_urls(opts={})
list = opts[:list]
max = opts[:max]
@@ -258,6 +274,7 @@ class UrlPlugin < Plugin
end
plugin = UrlPlugin.new
+plugin.map 'urls info *urls', :action => 'info'
plugin.map 'urls search :channel :limit :string', :action => 'search',
:defaults => {:limit => 4},
:requirements => {:limit => /^\d+$/},