summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/fish.rb
diff options
context:
space:
mode:
authorDmitry Kim <dmitry point kim at gmail point com>2007-03-29 22:19:06 +0000
committerDmitry Kim <dmitry point kim at gmail point com>2007-03-29 22:19:06 +0000
commitf21572a12c521bf244ca230991e830872754341c (patch)
tree53507f9911693eb37752f4be52bcf791a57fd545 /data/rbot/plugins/fish.rb
parent845f1f50df269091d645e78508fc833f539bb9b8 (diff)
+ support for non-iso-8859-1 languages (ru, zt, ja, ko, el)
Diffstat (limited to 'data/rbot/plugins/fish.rb')
-rw-r--r--data/rbot/plugins/fish.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/data/rbot/plugins/fish.rb b/data/rbot/plugins/fish.rb
index 68240659..8c115f90 100644
--- a/data/rbot/plugins/fish.rb
+++ b/data/rbot/plugins/fish.rb
@@ -3,11 +3,12 @@ require 'uri/common'
Net::HTTP.version_1_2
class BabelPlugin < Plugin
+ LANGS = %w{en fr de it pt es nl ru zh zt el ja ko}
def help(plugin, topic="")
- "translate to <lang> <string> => translate from english to <lang>, translate from <lang> <string> => translate to english from <lang>, translate <fromlang> <tolang> <string> => translate from <fromlang> to <tolang>. Languages: en, fr, de, it, pt, es, nl"
+ "translate to <lang> <string> => translate from english to <lang>, translate from <lang> <string> => translate to english from <lang>, translate <fromlang> <tolang> <string> => translate from <fromlang> to <tolang>. Languages: #{LANGS.join(', ')}"
end
def translate(m, params)
- langs = ["en", "fr", "de", "it", "pt", "es", "nl"]
+ langs = LANGS
trans_from = params[:fromlang] ? params[:fromlang] : 'en'
trans_to = params[:tolang] ? params[:tolang] : 'en'
trans_text = params[:phrase].to_s
@@ -31,9 +32,13 @@ class BabelPlugin < Plugin
http = @bot.httputil.get_proxy(URI.parse("http://babelfish.altavista.com"))
+ headers = {
+ "content-type" => "application/x-www-form-urlencoded; charset=utf-8",
+ 'accept-charset' => 'utf-8'
+ }
+
http.start {|http|
- resp = http.post(query, data, {"content-type",
- "application/x-www-form-urlencoded"})
+ resp = http.post(query, data, headers)
if (resp.code == "200")
lines = Array.new