: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 => 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',
end
def get_title_for_url(uri_str, depth=@bot.config['http.max_redir'])
# This god-awful mess is what the ruby http library has reduced me to.
# Python's HTTP lib is so much nicer. :~(
end
def get_title_for_url(uri_str, depth=@bot.config['http.max_redir'])
# This god-awful mess is what the ruby http library has reduced me to.
# Python's HTTP lib is so much nicer. :~(
debug "+ Getting #{uri_str.to_s}"
url = uri_str.kind_of?(URI) ? uri_str : URI.parse(uri_str)
return if url.scheme !~ /https?/
title = nil
debug "+ Getting #{uri_str.to_s}"
url = uri_str.kind_of?(URI) ? uri_str : URI.parse(uri_str)
return if url.scheme !~ /https?/
title = nil
debug "+ connecting to #{url.host}:#{url.port}"
http = @bot.httputil.get_proxy(url)
http.start { |http|
http.request_get(url.request_uri(), @bot.httputil.headers) { |response|
debug "+ connecting to #{url.host}:#{url.port}"
http = @bot.httputil.get_proxy(url)
http.start { |http|
http.request_get(url.request_uri(), @bot.httputil.headers) { |response|
else
return "[Link Info] Error getting link (#{response.code} - #{response.message})"
end # end of "case response"
else
return "[Link Info] Error getting link (#{response.code} - #{response.message})"
end # end of "case response"
url = Url.new(m.target, m.sourcenick, Time.new, urlstr)
debug "#{list.length} urls so far"
if list.length > @bot.config['url.max_urls']
url = Url.new(m.target, m.sourcenick, Time.new, urlstr)
debug "#{list.length} urls so far"
if list.length > @bot.config['url.max_urls']