]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/config.rb
introduce reload alias for rescan
[user/henk/code/ruby/rbot.git] / lib / rbot / core / config.rb
index 939b52991af568cb9c590aebe1cf2fb7e179effd..43d08829884a5606c64206129f5b36494f7c6061 100644 (file)
@@ -176,11 +176,27 @@ class ConfigModule < CoreBotModule
   end
 
   def bot_rescan(m, param)
-    m.reply _("saving ...")
-    @bot.save
-    m.reply _("rescanning ...")
-    @bot.rescan
-    m.reply _("done. %{plugin_status}") % {:plugin_status => @bot.plugins.status(true)}
+    if param[:botmodule]
+      name = param[:botmodule]
+      if not @bot.plugins.has_key? name
+        m.reply _("botmodule not found")
+        return # error
+      else
+        botmodule = @bot.plugins[name]
+        m.reply _("botmodule %s... saving... rescanning...") % [name]
+      end
+    else
+      m.reply _("saving... rescanning...")
+    end
+
+    @bot.rescan(botmodule)
+    m.reply _("done. %{plugin_status}") % {
+      :plugin_status => @bot.plugins.status(true)}
+    failure = @bot.plugins.botmodule_failure(name) if botmodule
+    if failure
+      m.reply _("plugin failed to load, %{failure}") % {
+        :failure => failure}
+    end
   end
 
   def bot_nick(m, param)
@@ -247,11 +263,13 @@ class ConfigModule < CoreBotModule
     when "save"
       _("save => save current dynamic data and configuration")
     when "rescan"
-      _("rescan => reload modules and static facts")
+      _("rescan [<botmodule>] => reload specified or all botmodules and static facts")
+    when "reload"
+      _("reload [<botmodule>] => reload specified or all botmodules and static facts")
     when "version"
       _("version => describes software version")
     else
-      _("config-related tasks: config, save, rescan, version, nick, status")
+      _("config-related tasks: config, save, rescan(/reload), version, nick, status")
     end
   end
 
@@ -281,7 +299,9 @@ conf.map 'config search *rx',
 
 conf.map "save",
   :action => 'bot_save'
-conf.map "rescan",
+conf.map "rescan [:botmodule]",
+  :action => 'bot_rescan'
+conf.map "reload [:botmodule]",
   :action => 'bot_rescan'
 conf.map "nick :nick",
   :action => 'bot_nick'