summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/rbot/plugins/translator.rb10
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