diff options
author | Raine Virta <rane@kapsi.fi> | 2009-04-30 01:35:28 +0300 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-04-30 13:46:49 +0200 |
commit | 834758616bf9e872c1a93dde83906cae9f893ee6 (patch) | |
tree | 0c763bbd4d081461641379abffa2ead3b9f9f66d /data/rbot | |
parent | 03d6142d434875204db8ac79d5bc0747f568539f (diff) |
translator: fix sentences not working with omitted language parameters
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/translator.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/data/rbot/plugins/translator.rb b/data/rbot/plugins/translator.rb index a8a31a5e..a32ea16d 100644 --- a/data/rbot/plugins/translator.rb +++ b/data/rbot/plugins/translator.rb @@ -318,6 +318,10 @@ class TranslatorPlugin < Plugin end end + def languages + @languages ||= @translators.map { |t| t.last.directions.keys }.flatten.uniq + end + def update_default @default_translators = bot.config['translator.default_list'] & @translators.keys end @@ -374,7 +378,9 @@ class TranslatorPlugin < Plugin end plugin = TranslatorPlugin.new +req = Hash[*%w(from to).map { |e| [e.to_sym, /#{plugin.languages.join("|")}/] }.flatten] + plugin.map 'translate [:from] [:to] *phrase', - :action => :cmd_translator, :thread => true + :action => :cmd_translator, :thread => true, :requirements => req plugin.map 'translator [:from] [:to] *phrase', - :action => :cmd_translator, :thread => true + :action => :cmd_translator, :thread => true, :requirements => req |