+
+ next unless list
+
+ # check to see if this url is already listed
+ next if list.find {|u| u.url == urlstr }
+
+ url = Url.new(m.target, m.sourcenick, Time.new, urlstr, title)
+ debug "#{list.length} urls so far"
+ list.pop if list.length > @bot.config['url.max_urls']
+ debug "storing url #{url.url}"
+ list.unshift url
+ debug "#{list.length} urls now"
+ end
+ @registry[m.target] = list
+ end
+
+ def info(m, params)
+ escaped = URI.escape(params[:urls].to_s, OUR_UNSAFE)
+ urls = URI.extract(escaped)
+ Thread.new { handle_urls(m, urls, params[:urls].length) }
+ end
+
+ def message(m)
+ return if m.address?
+
+ escaped = URI.escape(m.message, OUR_UNSAFE)
+ urls = URI.extract(escaped, ['http', 'https'])
+ return if urls.empty?
+ Thread.new { handle_urls(m, urls) }
+ end
+
+ def reply_urls(opts={})
+ list = opts[:list]
+ max = opts[:max]
+ channel = opts[:channel]
+ m = opts[:msg]
+ return unless list and max and m
+ list[0..(max-1)].each do |url|
+ disp = "[#{url.time.strftime('%Y/%m/%d %H:%M:%S')}] <#{url.nick}> #{url.url}"
+ if @bot.config['url.info_on_list']
+ title = url.info ||
+ get_title_for_url(url.url,
+ :nick => url.nick, :channel => channel) rescue nil
+ # If the url info was missing and we now have some, try to upgrade it
+ if channel and title and not url.info
+ ll = @registry[channel]
+ debug ll
+ if el = ll.find { |u| u.url == url.url }
+ el.info = title
+ @registry[channel] = ll
+ end
+ end
+ disp << " --> #{title}" if title
+ end
+ m.reply disp, :overlong => :truncate