]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
When a translator fails to initialize, map its command to respond the reason
authorYaohan Chen <yaohan.chen@gmail.com>
Mon, 30 Nov 2009 19:44:11 +0000 (14:44 -0500)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 30 Nov 2009 22:13:35 +0000 (23:13 +0100)
data/rbot/plugins/translator.rb

index d4f554440965d2708be76019bf81029f42264e07..8617c321e8196a2f86bebb69d3eba93893f62ede 100644 (file)
@@ -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]