extra << "#{Bold}type#{Bold}: #{resp['content-type']}" unless title
if enc = resp['content-encoding']
logopts[:extra] << ", encoding: #{enc}"
- extra << "#{Bold}encoding#{Bold}: #{enc}"
+ extra << "#{Bold}encoding#{Bold}: #{enc}" if @bot.config['url.first_par'] or not title
end
size = resp['content-length'].first.gsub(/(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/,'\1,\2') rescue nil
if size
logopts[:extra] << ", size: #{size} bytes"
- extra << "#{Bold}size#{Bold}: #{size} bytes"
+ extra << "#{Bold}size#{Bold}: #{size} bytes" if @bot.config['url.first_par'] or not title
end
end
rescue Exception => e
next unless urlstr =~ /^https?:/
title = nil
debug "Getting title for #{urlstr}..."
+ reply = nil
begin
title = get_title_for_url(urlstr,
:nick => m.source.nick,
:channel => m.channel,
:ircline => m.message)
debug "Title #{title ? '' : 'not '} found"
+ reply = "#{LINK_INFO} #{title}" if title
rescue => e
- m.reply "Error #{e.message}"
+ reply = "Error #{e.message}"
end
if display_info > urls_displayed
- if title
- m.reply("#{LINK_INFO} #{title}", :overlong => :truncate)
+ if reply
+ m.reply(reply, :overlong => :truncate)
urls_displayed += 1
end
end
return if m.address?
escaped = URI.escape(m.message, OUR_UNSAFE)
- urls = URI.extract(escaped)
+ urls = URI.extract(escaped, ['http', 'https'])
+ return if urls.empty?
Thread.new { handle_urls(m, urls) }
end