- begin
- urls = Array.new
-
- debug results
- results.each do |res|
- t = res[1].ircify_html(:img => "[%{src} %{alt} %{dimensions}]").strip
- u = res[0]
- if u.sub!(%r{^http://www.google.com/aclk\?},'')
- u = CGI::parse(u)['adurl'].first
- debug "skipping ad for #{u}"
- next
- elsif u.sub!(%r{^http://www.google.com/gwt/x\?},'')
- u = CGI::parse(u)['u'].first
- elsif u.sub!(%r{^/url\?},'')
- u = CGI::parse(u)['q'].first
- end
- urls.push(u)
- pretty.push("%{n}%{b}%{t}%{b}%{sep}%{u}" % {
- :n => (single ? "" : "#{urls.length}. "),
- :sep => (single ? " -- " : ": "),
- :b => Bold, :t => t, :u => u
- })
- break if urls.length == hits
- end
- rescue => e
- m.reply "failed to understand what google found for #{what}"
- error e
- debug wml
- debug results
- return
- end