6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/meme-bot/bot.rb', line 6
def self.init_config
directory = "#{ENV['HOME']}/.memebot"
unless File.directory? directory
Dir.mkdir directory
end
unless File.exist?("#{directory}/config.yml")
config_file = File.new("#{directory}/config.yml", "w+")
@config = { :server => 'localhost', :port => '6667', :nick => 'MemeBot', :channel => '#test' }
config_file.write(@config.to_yaml)
config_file.close
else
@config = YAML::load File.new("#{directory}/config.yml", "r").read
end
unless File.exist?("#{directory}/membot.yml")
File.new("#{directory}/membot.yml", "w").close
end
@config
end
|