]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/fish.rb
url plugin: customizable max amount of data to retrieve to look for a title. return...
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / fish.rb
index 57aaafc209955a2b24f684d88cc7285dbbadcf8d..6824065960edc2087f0e7a1c54d37a083204f117 100644 (file)
@@ -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+<td bgcolor=white class=s><div style=padding:10px;>(.*)<\/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+<td bgcolor=white class=s><div style=padding:10px;>(.*)<\/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