def initialize(bot)
@bot = bot
@users = Hash.new do
Struct::UserData.new(@bot.config['auth.default_level'], '', [])
end
@levels = Hash.new(0)
@currentUsers = Hash.new( nil )
if( File.exist?( "#{@bot.botclass}/users.yaml" ) )
File.open( "#{@bot.botclass}/users.yaml" ) { |file|
@loadedusers = YAML::parse(file).transform
@users.update(@loadedusers)
}
end
if(File.exist?("#{@bot.botclass}/levels.rbot"))
IO.foreach("#{@bot.botclass}/levels.rbot") do |line|
if(line =~ /\s*(\d+)\s*(\S+)/)
level = $1.to_i
command = $2
@levels[command] = level
end
end
end
if @levels.length < 1
raise RuntimeError, "No valid levels.rbot found! If you really want a free-for-all bot and this isn't the result of a previous error, write a proper levels.rbot"
end
end