Parent

Methods

Class/Module Index [+]

Quicksearch

Irc::Bot::Config::Wizard

Public Class Methods

new(bot) click to toggle source
# 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

Public Instance Methods

run() click to toggle source
# 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.