Class: Irc::Bot::Config::Wizard

Inherits:
Object
  • Object
show all
Defined in:
lib/rbot/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(bot) ⇒ Wizard

Returns a new instance of Wizard.



364
365
366
367
368
# File 'lib/rbot/config.rb', line 364

def initialize(bot)
  @bot = bot
  @manager = Config.manager
  @questions = @manager.items.values.find_all {|i| i.wizard }
end

Instance Method Details

#runObject



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/rbot/config.rb', line 370

def run()
  $stdout.sync = true
  puts _("First time rbot configuration wizard")
  puts "===================================="
  puts _("This is the first time you have run rbot with a config directory of: #{@bot.botclass}")
  puts _("This wizard will ask you a few questions to get you started.")
  puts _("The rest of rbot's configuration can be manipulated via IRC once rbot is connected and you are auth'd.")
  puts "-----------------------------------"

  return unless @questions
  @questions.sort{|a,b| a.order <=> b.order }.each do |q|
    puts _(q.desc)
    begin
      print q.key.to_s + " [#{q.to_s}]: "
      response = STDIN.gets
      response.chop!
      unless response.empty?
        q.set_string response, false
      end
      puts _("configured #{q.key} => #{q.to_s}")
      puts "-----------------------------------"
    rescue ArgumentError => e
      puts _("failed to set #{q.key}: #{e.message}")
      retry
    end
  end
end