diff options
author | Chris Gahan <chris@ill-logic.com> | 2007-03-14 06:50:39 +0000 |
---|---|---|
committer | Chris Gahan <chris@ill-logic.com> | 2007-03-14 06:50:39 +0000 |
commit | f9b784d241fbc90947f4282703b5b50d9c8d043b (patch) | |
tree | 22c001e2046bc0cc53b80e695bdd912c1b40031e /data/rbot | |
parent | b970f0d43f6bf69e4aec75120a9bf27b412ec331 (diff) |
Added config option: "url.titles_only"
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/url.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb index ca1e6ed8..e55999ee 100644 --- a/data/rbot/plugins/url.rb +++ b/data/rbot/plugins/url.rb @@ -10,6 +10,9 @@ class UrlPlugin < Plugin 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 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.)") def initialize super @@ -89,10 +92,12 @@ class UrlPlugin < Plugin data = read_data_from_response(response, 4096) return get_title_from_html(data) else - # content doesn't have title, just display info. - size = response['content-length'].gsub(/(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/,'\1,\2') - size = size ? ", size: #{size} bytes" : "" - return "[Link Info] type: #{response['content-type']}#{size}" + unless @bot.config['url.titles_only'] + # content doesn't have title, just display info. + size = response['content-length'].gsub(/(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/,'\1,\2') + size = size ? ", size: #{size} bytes" : "" + return "[Link Info] type: #{response['content-type']}#{size}" + end end else return "[Link Info] Error getting link (#{response.code} - #{response.message})" |