New attribute autoconnect in server tag
This commit is contained in:
parent
5bfcd61931
commit
22348e53b5
@ -170,6 +170,7 @@ def load_module(config, servers):
|
||||
|
||||
def load_file(filename, servers):
|
||||
"""Realy load a file"""
|
||||
global MODS
|
||||
config = xmlparser.parse_file(filename)
|
||||
if config.getName() == "nemubotconfig" or config.getName() == "config":
|
||||
#Preset each server in this file
|
||||
@ -180,6 +181,8 @@ def load_file(filename, servers):
|
||||
print (" Server `%s' successfully added." % srv.id)
|
||||
else:
|
||||
print (" Server `%s' already added, skiped." % srv.id)
|
||||
if srv.autoconnect:
|
||||
srv.launch(MODS)
|
||||
#Load files asked by the configuration file
|
||||
for load in config.getNodes("load"):
|
||||
load_file(load["path"], servers)
|
||||
|
@ -58,6 +58,14 @@ class Server(threading.Thread):
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def autoconnect(self):
|
||||
if self.node.hasAttribute("autoconnect"):
|
||||
value = self.node["autoconnect"].lower()
|
||||
return value != "no" and value != "off" and value != "false"
|
||||
else:
|
||||
return False
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self.host + ":" + str(self.port)
|
||||
|
Loading…
Reference in New Issue
Block a user