lib/protonbot/bot.rb in protonbot-0.2.1 vs lib/protonbot/bot.rb in protonbot-0.2.2
- old
+ new
@@ -24,18 +24,20 @@
@plugthrs = {}
Dir.mkdir('dbs/') unless File.exist?(File.expand_path('./dbs/'))
@conf['servers'].each do |k_, v_|
k = k_.clone
v = v_.clone
- @plugthrs[k] = Thread.new do
- @dbs[k] = Heliodor::DB.new("dbs/#{k}.db", true) unless k.nil?
- @plugs[k] = ProtonBot::Plug.new(self, k.clone, v.clone)
- begin
- @plugs[k].connect! if v['enabled'] || v['enabled'].nil?
- rescue => e
- @plugs[k].log_err(e)
+ @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|
@@ -45,11 +47,11 @@
end
@_log.stop
exit
end
- @plugthrs.each do |_k, v|
- v.join
+ @plugs.each do |_, p|
+ p.thrjoin
end
@_log.stop
end