Sha256: 9c2a2f22c76cf95cf2dd29d93ad17aa3f9eea862518432f603a319b6bf23e8e2

Contents?: true

Size: 1.12 KB

Versions: 20

Compression:

Stored size: 1.12 KB

Contents

class ProtonBot::Bot
  attr_reader :conf

  # @!group Config

  # Default server-config
  DEFAULT_SERVER_CONFIG = {
    'host' => '127.0.0.1',
    'port' => 6667,
    'user' => 'ProtonBot',
    'nick' => 'ProtonBot',
    'rnam' => 'An IRC bot in Ruby',
    'queue_delay' => 0.7,
    'cmdchar' => '\\',
    'encoding' => 'UTF-8',
    'autojoin' => []
  }.freeze

  # @yield Do your config-loading here
  # @see https://github.com/handicraftsman/heliodor/blob/master/config.md
  #   Config-description
  def configure(&block)
    if block
      @configure_block = block
    else
      @configure_block.call if @configure_block
      set 'tsafe', true
      @conf['servers'].each do |k, v|
        @conf['servers'][k] =
          DEFAULT_SERVER_CONFIG.merge(@conf['global'].to_h).merge(v.to_h)
      end
    end
  end

  # @param dat [Hash] Sets config variable to given value
  def gset(dat)
    raise(ArgumentError, '`dat` is not hash!') unless dat.instance_of?(Hash)
    @conf = dat
  end

  # Binds `val` to `key` in `@conf`
  # @param key [Symbol]
  # @param val [Object]
  def set(key, val)
    @conf[key.to_sym] = val
  end
  # @!endgroup
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
protonbot-0.3.7 lib/protonbot/bot_conf.rb
protonbot-0.3.6 lib/protonbot/bot_conf.rb
protonbot-0.3.5 lib/protonbot/bot_conf.rb
protonbot-0.3.4 lib/protonbot/bot_conf.rb
protonbot-0.3.3 lib/protonbot/bot_conf.rb
protonbot-0.3.2 lib/protonbot/bot_conf.rb
protonbot-0.3.1 lib/protonbot/bot_conf.rb
protonbot-0.3.0 lib/protonbot/bot_conf.rb
protonbot-0.2.7 lib/protonbot/bot_conf.rb
protonbot-0.2.6 lib/protonbot/bot_conf.rb
protonbot-0.2.5 lib/protonbot/bot_conf.rb
protonbot-0.2.4 lib/protonbot/bot_conf.rb
protonbot-0.2.3 lib/protonbot/bot_conf.rb
protonbot-0.2.2 lib/protonbot/bot_conf.rb
protonbot-0.2.1 lib/protonbot/bot_conf.rb
protonbot-0.2.0 lib/protonbot/bot_conf.rb
protonbot-0.1.3 lib/protonbot/bot_conf.rb
protonbot-0.1.2 lib/protonbot/bot_conf.rb
protonbot-0.1.1 lib/protonbot/bot_conf.rb
protonbot-0.1.0 lib/protonbot/bot_conf.rb