From 834758616bf9e872c1a93dde83906cae9f893ee6 Mon Sep 17 00:00:00 2001 From: Raine Virta Date: Thu, 30 Apr 2009 01:35:28 +0300 Subject: translator: fix sentences not working with omitted language parameters --- data/rbot/plugins/translator.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'data/rbot/plugins') 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 -- cgit v1.2.3