From 7993226963ede0c50da4d32d2ba877c97736ad5c Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 25 Jan 2012 09:44:40 +0100 Subject: search: fix gcalc Google changed their layout again. To be a little more future-proof, split the html into as many
sections as there are, and pick the first one that contains the literal string ' = ' if there is one. --- data/rbot/plugins/search.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/data/rbot/plugins/search.rb b/data/rbot/plugins/search.rb index 60a70c54..2a1b3dc1 100644 --- a/data/rbot/plugins/search.rb +++ b/data/rbot/plugins/search.rb @@ -183,13 +183,15 @@ class SearchPlugin < Plugin debug "#{html.size} bytes of html recieved" - intro, result, junk = html.split(/\s*\s*/, 3) - debug "result: #{result.inspect}" + splits = html.split(/\s*\s*/) + candidates = splits.select { |section| section.include? ' = ' } + debug "candidates: #{candidates.inspect}" - unless result.include? '=' + if candidates.empty? m.reply "couldn't calculate #{what}" return end + result = candidates.first debug "replying with: #{result.inspect}" m.reply result.ircify_html -- cgit v1.2.3