Class: MemeBot

Inherits:
Isaac::Bot
  • Object
show all
Defined in:
lib/meme-bot/bot.rb

Class Method Summary collapse

Class Method Details

.configurationObject



29
30
31
# File 'lib/meme-bot/bot.rb', line 29

def self.configuration
  @config ||= self.init_config
end

.init_configObject



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