Reduce useless nesting in configuration files
parent
e912898dd0
commit
0de5a39c5a
|
@ -6,28 +6,19 @@ require 'yaml'
|
||||||
|
|
||||||
module Vrobot4
|
module Vrobot4
|
||||||
private
|
private
|
||||||
def self.loadServer servinfo
|
def self.loadBot botinfo
|
||||||
type = servinfo["type"]
|
type = botinfo["type"]
|
||||||
|
serv = Server::get_server_type(type).new(botinfo)
|
||||||
|
|
||||||
serv = Server::get_server_type(type).new(servinfo)
|
botinfo["modules"].each \
|
||||||
|
{|mod| serv.load_mod mod} if botinfo.key? "modules"
|
||||||
servinfo["modules"].each \
|
|
||||||
{|mod| serv.load_mod mod} if servinfo.key? "modules"
|
|
||||||
|
|
||||||
serv
|
serv
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.loadBot botinfo
|
|
||||||
servers = []
|
|
||||||
botinfo["servers"].each {|servinfo| servers << loadServer(servinfo)}
|
|
||||||
{info: botinfo, servs: servers}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.runBots bots
|
def self.runBots bots
|
||||||
thrds = []
|
thrds = []
|
||||||
bots.each do |bot|
|
bots.each {|serv| thrds << Thread.new {serv.connect}}
|
||||||
bot[:servs].each {|serv| thrds << Thread.new {serv.connect}}
|
|
||||||
end
|
|
||||||
thrds.each {|th| th.join}
|
thrds.each {|th| th.join}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue