Sha256: 359e7a76f791e4e5d40f941d89fb056e34e9636fa3d16b4ec5b03e057bd6f778
Contents?: true
Size: 1.47 KB
Versions: 4
Compression:
Stored size: 1.47 KB
Contents
# Main bot class. Use it to create the bot class ProtonBot::Bot attr_reader :log, :_log, :dbs, :plugins, :conf, :plugs, :plugthrs, :core # @yield Main bot's block. You'll use it for configuring bot. def initialize(&block) @_log = ProtonBot::Log.new @log = @_log.wrap('main') @log.info('Hi there!') instance_exec(&block) @log.info('Processed main block') @conf = {} configure @log.info('Processed config block') @parr = [] @plugins = {} plugins_load @log.info('Processed plugins block') @dbs = {} @plugs = {} @plugthrs = {} Dir.mkdir('dbs/') unless File.exist?(File.expand_path('./dbs/')) @conf['servers'].each do |k_, v_| k = k_.clone v = v_.clone @dbs[k] = Heliodor::DB.new("dbs/#{k}.db", true) unless k.nil? @plugs[k] = ProtonBot::Plug.new(self, k.clone, v.clone) begin if v['enabled'] || v['enabled'].nil? Thread.new do @plugs[k].connect! end end rescue => e @plugs[k].log_err(e) end end Signal.trap('INT') do @plugs.each do |_k, v| @log.info('Stopping...') v.write_('QUIT :Stopping...') v.running = false end @_log.stop exit end @plugs.each do |_, p| p.thrjoin end @_log.stop end def inspect %(<#ProtonBot::Bot:#{object_id.to_s(16)}>) end module Messages NOT_ENOUGH_PARAMETERS = 'Not enough parameters!'.freeze end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
protonbot-0.3.6 | lib/protonbot/bot.rb |
protonbot-0.3.5 | lib/protonbot/bot.rb |
protonbot-0.3.4 | lib/protonbot/bot.rb |
protonbot-0.3.3 | lib/protonbot/bot.rb |