From 550754633ba85f5bd633dc81aeee686ead45774d Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 6 Apr 2007 20:59:04 +0000 Subject: fish plugin: use get instead of get_response and resp.body.each_line --- data/rbot/plugins/fish.rb | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'data') diff --git a/data/rbot/plugins/fish.rb b/data/rbot/plugins/fish.rb index 25816024..76555a34 100644 --- a/data/rbot/plugins/fish.rb +++ b/data/rbot/plugins/fish.rb @@ -55,41 +55,34 @@ class BabelPlugin < Plugin query = "/babelfish/tr" begin - resp = @bot.httputil.get_response('http://babelfish.altavista.com'+query, - :method => :post, - :body => data, - :headers => headers) + body = @bot.httputil.get('http://babelfish.altavista.com'+query, + :method => :post, + :body => data, + :headers => headers) rescue Exception => e m.reply "http error: #{e.message}" return end - if (resp.code == "200") - lines = Array.new - resp.body.each_line { |l| lines.push l } - - l = lines.join(" ") - debug "babelfish response: #{l}" - - case l - when /^\s+
(.*)<\/div><\/td>\s*<\/tr>/m - answer = $1.gsub(/\s*[\r\n]+\s*/,' ') - # cache the answer - if(answer.length > 0) - @registry["#{trans_pair}/#{data_text}"] = answer - end - m.reply answer - return - when /^\s+