From efbd4bea3ef18d2a3649dc7a5159e0e910ba7149 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 14 Oct 2010 11:16:02 +0200 Subject: search: gcalc fix Google changed their HTML again, breaking gcalc. Fix by using the WAP search and get the first result if it contains an equal sign. --- data/rbot/plugins/search.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'data/rbot') diff --git a/data/rbot/plugins/search.rb b/data/rbot/plugins/search.rb index dc525929..4e13f3e7 100644 --- a/data/rbot/plugins/search.rb +++ b/data/rbot/plugins/search.rb @@ -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) -- cgit v1.2.3