- # bot:: parent bot class
- # create a new config hash from #{botclass}/conf.rbot
- def initialize(bot)
- @@bot = bot
-
- # respond to config messages, to provide runtime configuration
- # management
- # messages will be:
- # get
- # set
- # unset
- # desc
- # and for arrays:
- # add TODO
- # remove TODO
- @handler = MessageMapper.new(self)
- @handler.map 'config list :module', :action => 'handle_list',
- :defaults => {:module => false}
- @handler.map 'config get :key', :action => 'handle_get'
- @handler.map 'config desc :key', :action => 'handle_desc'
- @handler.map 'config describe :key', :action => 'handle_desc'
- @handler.map 'config set :key *value', :action => 'handle_set'
- @handler.map 'config unset :key', :action => 'handle_unset'
- @handler.map 'config help :topic', :action => 'handle_help',
- :defaults => {:topic => false}
- @handler.map 'help config :topic', :action => 'handle_help',
- :defaults => {:topic => false}
-
- if(File.exist?("#{@@bot.botclass}/conf.yaml"))
- begin
- newconfig = YAML::load_file("#{@@bot.botclass}/conf.yaml")
- @@config.update newconfig
- return
- rescue
- $stderr.puts "failed to read conf.yaml: #{$!}"
- end
- end
- # if we got here, we need to run the first-run wizard
- BotConfigWizard.new(@@bot).run
- # save newly created config
- save
+ # pass everything else through to the hash
+ def method_missing(method, *args, &block)
+ return @config.send(method, *args, &block)