summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/url.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-12 08:30:33 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-12 08:30:33 +0000
commitbf03d9f2b695772212abee81d405483c5c374633 (patch)
tree6b196920d3b21833ba8ef34f1d491cdf23f07354 /data/rbot/plugins/url.rb
parent37fb9f96d582d24ffb9bbc14cc75fc9fec52ace3 (diff)
url plugin: search for user-provided string in urls info too; and truly update url info when it wasn't present before
Diffstat (limited to 'data/rbot/plugins/url.rb')
-rw-r--r--data/rbot/plugins/url.rb24
1 files changed, 18 insertions, 6 deletions
diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb
index 8c064dcc..62fc5588 100644
--- a/data/rbot/plugins/url.rb
+++ b/data/rbot/plugins/url.rb
@@ -146,13 +146,24 @@ class UrlPlugin < Plugin
end
end
- def reply_urls(m, list, max)
+ def reply_urls(opts={})
+ list = opts[:list]
+ max = opts[:max]
+ channel = opts[:channel]
+ m = opts[:msg]
+ return unless list and max and m
list[0..(max-1)].each do |url|
disp = "[#{url.time.strftime('%Y/%m/%d %H:%M:%S')}] <#{url.nick}> #{url.url}"
if @bot.config['url.info_on_list']
title = url.info || get_title_for_url(url.url) rescue nil
- if title and not url.info
- url.info = title
+ # If the url info was missing and we now have some, try to upgrade it
+ if channel and title and not url.info
+ ll = @registry[channel]
+ debug ll
+ if el = ll.find { |u| u.url == url.url }
+ el.info = title
+ @registry[channel] = ll
+ end
end
disp << " --> #{title}" if title
end
@@ -169,7 +180,7 @@ class UrlPlugin < Plugin
if list.empty?
m.reply "no urls seen yet for channel #{channel}"
else
- reply_urls(m, list, max)
+ reply_urls :msg => m, :channel => channel, :list => list, :max => max
end
end
@@ -181,12 +192,13 @@ class UrlPlugin < Plugin
max = 1 if max < 1
regex = Regexp.new(string, Regexp::IGNORECASE)
list = @registry[channel].find_all {|url|
- regex.match(url.url) || regex.match(url.nick)
+ regex.match(url.url) || regex.match(url.nick) ||
+ (@bot.config['url.info_on_list'] && regex.match(url.info))
}
if list.empty?
m.reply "no matches for channel #{channel}"
else
- reply_urls(m, list, max)
+ reply_urls :msg => m, :channel => channel, :list => list, :max => max
end
end
end