Sha256: 08a6adc48481fbe8d8cb5eac83a270f76b1b0ae54b1cd5d4e8369a4e32a36846

Contents?: true

Size: 816 Bytes

Versions: 1

Compression:

Stored size: 816 Bytes

Contents

require 'isaac/bot'
require 'eventmachine'
require 'yaml'

class MemeBot < Isaac::Bot
  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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
meme-bot-0.0.1 lib/meme-bot/bot.rb