Class: CrazyDoll::Bot

Inherits:
Object
  • Object
show all
Defined in:
lib/crazy_doll/bot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ Bot

Returns a new instance of Bot.



5
6
7
8
9
10
11
12
13
14
# File 'lib/crazy_doll/bot.rb', line 5

def initialize(config=nil)
  @config         = config || CrazyDoll::Config.new('yaml', File.join(ENV['HOME'], '.crazy_doll','database.yaml'))
  core_config     = @config.config_of 'Core'
  @irc            = CrazyDoll::IRC.new(core_config.server, core_config.port)
  @event_manager  = CrazyDoll::EventManager.new(@irc)
  @plugin_manager = CrazyDoll::PluginManager
  @plugin_manager.load_plugins
  @plugin_manager.find_usable_errors
  @plugin_manager.register_plugins(@event_manager, @config)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/crazy_doll/bot.rb', line 4

def config
  @config
end

#event_managerObject (readonly)

Returns the value of attribute event_manager.



4
5
6
# File 'lib/crazy_doll/bot.rb', line 4

def event_manager
  @event_manager
end

#ircObject (readonly)

Returns the value of attribute irc.



4
5
6
# File 'lib/crazy_doll/bot.rb', line 4

def irc
  @irc
end

#plugin_managerObject (readonly)

Returns the value of attribute plugin_manager.



4
5
6
# File 'lib/crazy_doll/bot.rb', line 4

def plugin_manager
  @plugin_manager
end

Instance Method Details

#startObject



16
17
18
19
20
21
22
23
# File 'lib/crazy_doll/bot.rb', line 16

def start
  @config.start_use
  begin
    @irc.start
  ensure
    @config.end_use
  end
end