summaryrefslogtreecommitdiff
path: root/data/rbot/plugins
diff options
context:
space:
mode:
authorRaine Virta <rane@kapsi.fi>2009-04-30 00:40:54 +0300
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-04-30 13:46:25 +0200
commit88b3cb20e4aa317cba5ea419a8d77833e76da36c (patch)
treef2289e34c79e9b1da62f1dd15a3438b4cc3bc8c3 /data/rbot/plugins
parentf16c5d38c3ca206557434ecae6665c128831ebc8 (diff)
translator: make destination language optional
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r--data/rbot/plugins/translator.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/data/rbot/plugins/translator.rb b/data/rbot/plugins/translator.rb
index 0e09cb48..a046b206 100644
--- a/data/rbot/plugins/translator.rb
+++ b/data/rbot/plugins/translator.rb
@@ -266,6 +266,9 @@ class TranslatorPlugin < Plugin
Config.register Config::IntegerValue.new('translator.timeout',
:default => 30, :validate => Proc.new{|v| v > 0},
:desc => _("Number of seconds to wait for the translation service before timeout"))
+ Config.register Config::StringValue.new('translator.destination',
+ :default => "en",
+ :desc => _("Default destination language to be used with translate command"))
TRANSLATORS = {
'nifty' => NiftyTranslator,
@@ -320,8 +323,9 @@ class TranslatorPlugin < Plugin
end
def cmd_translator(m, params)
- from, to = params[:from], params[:to]
- translator = @default_translators.find {|t| @translators[t].support?(from, to)}
+ params[:to] = @bot.config['translator.destination'] if params[:to].nil?
+
+ translator = @default_translators.find {|t| @translators[t].support?(params[:from], params[:to])}
if translator
cmd_translate m, params.merge({:translator => translator, :show_provider => true})
else
@@ -362,5 +366,5 @@ class TranslatorPlugin < Plugin
end
plugin = TranslatorPlugin.new
-plugin.map 'translator :from :to *phrase',
+plugin.map 'translator :from [:to] *phrase',
:action => :cmd_translator, :thread => true