From ea3e6deb696f6336fef8680140db818b8237d0bf Mon Sep 17 00:00:00 2001 From: Alexander Beisig Date: Tue, 17 Oct 2006 11:44:57 +0000 Subject: Hopefully made the babelfish plugin a bit more robust --- data/rbot/plugins/fish.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'data/rbot/plugins') diff --git a/data/rbot/plugins/fish.rb b/data/rbot/plugins/fish.rb index 57aaafc2..68240659 100644 --- a/data/rbot/plugins/fish.rb +++ b/data/rbot/plugins/fish.rb @@ -36,16 +36,22 @@ class BabelPlugin < Plugin "application/x-www-form-urlencoded"}) if (resp.code == "200") + lines = Array.new resp.body.each_line do |l| - if(l =~ /^\s+
(.*)<\/div>/) - answer = $1 - # cache the answer - if(answer.length > 0) - @registry["#{trans_pair}/#{data_text}"] = answer - end - m.reply answer - return + lines.push l + end + + l = lines.join(" ") + debug "babelfish response: #{l}" + + if(l =~ /^\s+
(.*)<\/div>/) + answer = $1 + # cache the answer + if(answer.length > 0) + @registry["#{trans_pair}/#{data_text}"] = answer end + m.reply answer + return end m.reply "couldn't parse babelfish response html :(" else -- cgit v1.2.3