From f9b784d241fbc90947f4282703b5b50d9c8d043b Mon Sep 17 00:00:00 2001 From: Chris Gahan Date: Wed, 14 Mar 2007 06:50:39 +0000 Subject: Added config option: "url.titles_only" --- data/rbot/plugins/url.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'data') 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 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})" -- cgit v1.2.3