summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaohan Chen <yaohan.chen@gmail.com>2009-11-30 14:44:11 -0500
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-11-30 23:13:35 +0100
commitc3e2d59d3e081141fcdcd5ee43469c3c4a7586db (patch)
treef5bcfefe1e1999921fb108b1d44d37c7a37145ed
parent657e1d70928f2878d4c256825632265fe59b2269 (diff)
When a translator fails to initialize, map its command to respond the reason
-rw-r--r--data/rbot/plugins/translator.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/data/rbot/plugins/translator.rb b/data/rbot/plugins/translator.rb
index d4f55444..8617c321 100644
--- a/data/rbot/plugins/translator.rb
+++ b/data/rbot/plugins/translator.rb
@@ -284,6 +284,8 @@ class TranslatorPlugin < Plugin
rescue Exception
warning _("Translator %{name} cannot be used: %{reason}") %
{:name => name, :reason => $!}
+ map "#{name} [*args]", :action => :failed_translator,
+ :defaults => {:name => name, :reason => $!}
end
end
@@ -295,6 +297,11 @@ class TranslatorPlugin < Plugin
update_default
end
+ def failed_translator(m, params)
+ m.reply _("Translator %{name} cannot be used: %{reason}") %
+ {:name => params[:name], :reason => params[:reason]}
+ end
+
def help(plugin, topic=nil)
if @translators.has_key?(plugin)
translator = @translators[plugin]