X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=data%2Frbot%2Fplugins%2Fsearch.rb;h=4e13f3e7f7ec7dd9d539a655f5b56400fc48afbe;hb=052217de30c59206d7025b582d4604557a747470;hp=8b3b6848d11800084a22ac93a9b64d3c13802207;hpb=d372ec5babdbf5e6a9c49b21d16bcae74d0ff01c;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/search.rb b/data/rbot/plugins/search.rb index 8b3b6848..4e13f3e7 100644 --- a/data/rbot/plugins/search.rb +++ b/data/rbot/plugins/search.rb @@ -19,7 +19,7 @@ GOOGLE_SEARCH = "http://www.google.com/search?oe=UTF-8&q=" GOOGLE_WAP_SEARCH = "http://www.google.com/m/search?hl=en&q=" # GOOGLE_WAP_LINK = /(.*?)<\/a>/im GOOGLE_WAP_LINK = /(.*?)<\/a>/im -GOOGLE_CALC_RESULT = %r{.*?

]*>(.+?)} +GOOGLE_CALC_RESULT = %r{.*?]*>(.+?)} GOOGLE_COUNT_RESULT = %r{Results 1<\/b> - 10<\/b> of about (.*)<\/b> for} GOOGLE_DEF_RESULT = %r{]*>(Web definitions for .*?)
(.*?)
(.*?)\s-\s+
]+>(.+?)<(br|/td)>} @@ -172,7 +172,7 @@ class SearchPlugin < Plugin searchfor = CGI.escape(what) debug "Getting gcalc thing: #{searchfor.inspect}" - url = GOOGLE_SEARCH + searchfor + url = GOOGLE_WAP_SEARCH + searchfor begin html = @bot.httputil.get(url) @@ -183,17 +183,16 @@ class SearchPlugin < Plugin debug "#{html.size} bytes of html recieved" - results = html.scan(GOOGLE_CALC_RESULT) - debug "results: #{results.inspect}" + intro, result, junk = html.split(/\s*\s*/, 3) + debug "result: #{result.inspect}" - if results.length != 1 + unless result.include? '=' m.reply "couldn't calculate #{what}" return end - result = results[0][0].ircify_html debug "replying with: #{result.inspect}" - m.reply "#{result}" + m.reply result.ircify_html end def gcount(m, params)