def save
if not @changed
debug "Not writing conf.yaml (unchanged)"
return
end
begin
debug "Writing new conf.yaml ..."
File.open("#{@bot.botclass}/conf.yaml.new", "w") do |file|
savehash = {}
@config.each { |key, val|
savehash[key.to_s] = val
}
file.puts savehash.to_yaml
end
debug "Officializing conf.yaml ..."
File.rename("#{@bot.botclass}/conf.yaml.new",
"#{@bot.botclass}/conf.yaml")
@changed = false
rescue => e
error "failed to write configuration file conf.yaml! #{$!}"
error "#{e.class}: #{e}"
error e.backtrace.join("\n")
end
end