summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-06-24 11:01:48 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-06-24 12:29:58 +0200
commit9487a04ec88c8c55e8097664dcc74e79e87162d6 (patch)
treeeb9cb5c594e270c93107e710fb09c5de2ede3721 /lib
parent2fc4905ccafb89ca8b9bed1a52f6677e60eb89fd (diff)
config.rb: system wide overrides in /etc/rbot.conf
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/config.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/rbot/config.rb b/lib/rbot/config.rb
index 90610379..207264bf 100644
--- a/lib/rbot/config.rb
+++ b/lib/rbot/config.rb
@@ -40,7 +40,9 @@ module Config
@order = @@order
@@order += 1
@key = key.to_sym
- if params.has_key? :default
+ if @manager.overrides.key?(@key)
+ @default = @manager.overrides[@key]
+ elsif params.has_key? :default
@default = params[:default]
else
@default = false
@@ -226,6 +228,7 @@ module Config
attr_reader :bot
attr_reader :items
attr_reader :config
+ attr_reader :overrides
attr_accessor :changed
def initialize
@@ -235,6 +238,21 @@ module Config
def reset_config
@items = Hash.new
@config = Hash.new(false)
+
+ # We allow default values for config keys to be overridden by
+ # the config file /etc/rbot.conf
+ # The main purpose for this is to allow distro or system-wide
+ # settings such as external program paths (figlet, toilet, ispell)
+ # to be set once for all the bots.
+ @overrides = Hash.new
+ etcfile = "/etc/rbot.conf"
+ if File.exist?(etcfile)
+ log "Loading defaults from #{etcfile}"
+ etcconf = YAML::load_file(etcfile)
+ etcconf.each { |k, v|
+ @overrides[k.to_sym] = v
+ }
+ end
end
# Associate with bot _bot_