class Qbot::Application
Attributes
logger[R]
timers[R]
Public Class Methods
new()
click to toggle source
# File lib/qbot/app.rb, line 27 def initialize @bots = [] @help = {} @threads = [] @timers = Timers::Group.new @logger = Logger.new(STDOUT) end
Public Instance Methods
adapter()
click to toggle source
# File lib/qbot/app.rb, line 60 def adapter @adapter ||= Qbot::Adapter::Driver.build end
add_bot(bot)
click to toggle source
# File lib/qbot/app.rb, line 35 def add_bot(bot) @bots << bot end
help_text(usages = {})
click to toggle source
# File lib/qbot/app.rb, line 39 def help_text(usages = {}) @help.update(usages) end
start()
click to toggle source
# File lib/qbot/app.rb, line 43 def start @logger.info("Booting #{self.class}.") @logger.info("#{storage.class} - Storage driver loaded.") @logger.info("#{adapter.class} - Adapter driver loaded.") @bots.map { |bot| bot.class.name }.uniq.each { |bot| @logger.info("#{bot} loaded.") } Thread.abort_on_exception = true @threads << Thread.start { loop { @timers.wait } } @threads << Thread.start { adapter.run(@bots) } @threads.each { |th| th.join } end
stop()
click to toggle source
# File lib/qbot/app.rb, line 55 def stop adapter.close if adapter.respond_to?(:close) @threads.each { |th| th.kill if th } end
storage()
click to toggle source
# File lib/qbot/app.rb, line 64 def storage @storage ||= Qbot::Storage::Driver.build end