]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Core botmodule config.rb has some (very little) facility to ease config key setting...
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 30 Jan 2007 14:13:37 +0000 (14:13 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 30 Jan 2007 14:13:37 +0000 (14:13 +0000)
lib/rbot/core/config.rb

index 1fe2da22d041aef016cc1d3a719af87cb98cd3c2..9ef7ebeef6008bad1ea1239cf9e1de956fce875f 100644 (file)
@@ -66,22 +66,25 @@ class ConfigModule < CoreBotModule
     key = params[:key].to_s.intern\r
     value = params[:value].join(" ")\r
     unless @bot.config.items.has_key?(key)\r
-      m.reply "no such config key #{key}"\r
-      return\r
+      m.reply "no such config key #{key}" unless params[:silent]\r
+      return false\r
     end\r
-    return if !@bot.auth.allow?(@bot.config.items[key].auth_path, m.source, m.replyto)\r
+    return false if !@bot.auth.allow?(@bot.config.items[key].auth_path, m.source, m.replyto)\r
     begin\r
       @bot.config.items[key].set_string(value)\r
     rescue ArgumentError => e\r
-      m.reply "failed to set #{key}: #{e.message}"\r
-      return\r
+      m.reply "failed to set #{key}: #{e.message}" unless params[:silent]\r
+      return false\r
     end\r
     if @bot.config.items[key].requires_restart\r
-      m.reply "this config change will take effect on the next restart"\r
+      m.reply "this config change will take effect on the next restart" unless params[:silent]\r
+      return :restart\r
     elsif @bot.config.items[key].requires_rescan\r
-      m.reply "this config change will take effect on the next rescan"\r
+      m.reply "this config change will take effect on the next rescan" unless params[:silent]\r
+      return :rescan\r
     else\r
-      m.okay\r
+      m.okay unless params[:silent]\r
+      return true\r
     end\r
   end\r
 \r