diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-10-14 11:16:02 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-10-14 11:16:02 +0200 |
commit | efbd4bea3ef18d2a3649dc7a5159e0e910ba7149 (patch) | |
tree | 88e9f84b5589a3a9be25ac82745bfba3f89717bb /data/rbot | |
parent | 87d2affc0fbe7cf864fdad4eca506d9d06a0de0c (diff) |
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.
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/search.rb | 11 |
1 files changed, 5 insertions, 6 deletions
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*<br\/>\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) |