summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-08-23 08:41:06 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-08-23 08:41:06 +0000
commit3ae571e67d5a40e7f9fb4694b16e6feb1ec1466e (patch)
treed71efd888863656aad39b196b49996be7191e762
parent6fde22f9311f0e009766bd1f190786c63a84a7b4 (diff)
url plugin: url.display_link_info is now an Integer: the number of links in a line for which info should be displayed
-rw-r--r--data/rbot/plugins/url.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb
index 77793b93..c3463d5d 100644
--- a/data/rbot/plugins/url.rb
+++ b/data/rbot/plugins/url.rb
@@ -11,9 +11,9 @@ class UrlPlugin < Plugin
BotConfig.register BotConfigIntegerValue.new('url.max_urls',
:default => 100, :validate => Proc.new{|v| v > 0},
:desc => "Maximum number of urls to store. New urls replace oldest ones.")
- BotConfig.register BotConfigBooleanValue.new('url.display_link_info',
- :default => false,
- :desc => "Get the title of any links pasted to the channel and display it (also tells if the link is broken or the site is down)")
+ BotConfig.register BotConfigIntegerValue.new('url.display_link_info',
+ :default => 0,
+ :desc => "Get the title of links pasted to the channel and display it (also tells if the link is broken or the site is down). Do it for at most this many links per line (set to 0 to disable)")
BotConfig.register BotConfigBooleanValue.new('url.titles_only',
:default => false,
:desc => "Only show info for links that have <title> tags (in other words, don't display info for jpegs, mpegs, etc.)")
@@ -28,6 +28,9 @@ class UrlPlugin < Plugin
def initialize
super
@registry.set_default(Array.new)
+ unless @bot.config['url.display_link_info'].kind_of?(Integer)
+ @bot.config.items[:'url.display_link_info'].set_string(@bot.config['url.display_link_info'].to_s)
+ end
end
def help(plugin, topic="")
@@ -138,11 +141,14 @@ class UrlPlugin < Plugin
return if urls.empty?
debug "found urls #{urls.inspect}"
list = @registry[m.target]
+ urls_displayed = 0
urls.each { |urlstr|
debug "working on #{urlstr}"
next unless urlstr =~ /^https?:/
title = nil
- if @bot.config['url.display_link_info']
+ debug "display link info: #{@bot.config['url.display_link_info']}"
+ if @bot.config['url.display_link_info'] > urls_displayed
+ urls_displayed += 1
Thread.start do
debug "Getting title for #{urlstr}..."
begin