]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/search.rb
url plugin: revert to block get_response and partial_body to work around sites which...
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / search.rb
index aea6dc4cc4a5f9061261eeb2b88471118b1dc22f..c733c815fd03481b1b5a2451437f3a9e9a6ea852 100644 (file)
 # TODO:: use lr=lang_<code> or whatever is most appropriate to let google know
 #        it shouldn't use the bot's location to find the preferred language
 
-require 'uri'
-
-Net::HTTP.version_1_2
-
 GOOGLE_WAP_LINK = /<a accesskey="(\d)" href=".*?u=(.*?)">(.*?)<\/a>/im
 GOOGLE_CALC_RESULT = %r{<p><table><tr><td><img src=/images/calc_img\.gif></td><td>&nbsp;</td><td nowrap><font size=\+1><b>(.+)</b></td></tr><tr><td>}
 
@@ -49,7 +45,7 @@ class SearchPlugin < Plugin
 
   def google(m, params)
     what = params[:words].to_s
-    searchfor = URI.escape what
+    searchfor = CGI.escape what
     # This method is also called by other methods to restrict searching to some sites
     if params[:site]
       site = "site:#{params[:site]}+"
@@ -97,7 +93,7 @@ class SearchPlugin < Plugin
 
   def gcalc(m, params)
     what = params[:words].to_s
-    searchfor = URI.escape(what).sub('+','%2B')
+    searchfor = CGI.escape(what)
     
     debug "Getting gcalc thing: #{searchfor.inspect}"
     url = "http://www.google.com/search?q=#{searchfor}"