Update examples and change how variables used when reconnecting are set
This commit is contained in:
parent
88426be62a
commit
aacb50d5d2
|
@ -21,10 +21,10 @@
|
|||
"protocol": null,
|
||||
"bind": null,
|
||||
"timeout": 30,
|
||||
"maxdelay": 5,
|
||||
"initialdelay": 1,
|
||||
"factor": 2,
|
||||
"jitter": 5,
|
||||
"maxdelay": 360,
|
||||
"initialdelay": 1.0,
|
||||
"factor": 2.7182818284590451,
|
||||
"jitter": 0.11962656472,
|
||||
"nickname": null,
|
||||
"username": null,
|
||||
"realname": null,
|
||||
|
|
33
threshold
33
threshold
|
@ -251,6 +251,7 @@ class IRCBotFactory(ReconnectingClientFactory):
|
|||
def __init__(self, name):
|
||||
self.instance = pool[name]
|
||||
self.name = name
|
||||
self.client = None
|
||||
self.maxDelay = self.instance["maxdelay"]
|
||||
self.initialDelay = self.instance["initialdelay"]
|
||||
self.factor = self.instance["factor"]
|
||||
|
@ -264,8 +265,9 @@ class IRCBotFactory(ReconnectingClientFactory):
|
|||
return entry
|
||||
|
||||
def clientConnectionLost(self, connector, reason):
|
||||
self.client.connected = False
|
||||
self.client.channels = []
|
||||
if not self.client == None:
|
||||
self.client.connected = False
|
||||
self.client.channels = []
|
||||
error = reason.getErrorMessage()
|
||||
log("%s: connection lost: %s" % (self.name, error))
|
||||
helper.sendAll("%s: connection lost: %s" % (self.name, error))
|
||||
|
@ -273,8 +275,9 @@ class IRCBotFactory(ReconnectingClientFactory):
|
|||
#ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
|
||||
|
||||
def clientConnectionFailed(self, connector, reason):
|
||||
self.client.connected = False
|
||||
self.client.channels = []
|
||||
if not self.client == None:
|
||||
self.client.connected = False
|
||||
self.client.channels = []
|
||||
error = reason.getErrorMessage()
|
||||
log("%s: connection failed: %s" % (self.name, error))
|
||||
helper.sendAll("%s: connection failed: %s" % (self.name, error))
|
||||
|
@ -963,6 +966,10 @@ class Helper(object):
|
|||
"protocol": protocol,
|
||||
"bind": config["Default"]["bind"],
|
||||
"timeout": config["Default"]["timeout"],
|
||||
"maxdelay": config["Default"]["maxdelay"],
|
||||
"initialdelay": config["Default"]["initialdelay"],
|
||||
"factor": config["Default"]["factor"],
|
||||
"jitter": config["Default"]["jitter"],
|
||||
"nickname": nickname,
|
||||
"username": config["Default"]["username"],
|
||||
"realname": config["Default"]["realname"],
|
||||
|
@ -1024,13 +1031,20 @@ class Helper(object):
|
|||
spl[2] = None
|
||||
toUnset = True
|
||||
|
||||
if spl[1] in ["port", "timeout", "maxdelay", "initialdelay", "factor", "jitter"]:
|
||||
if spl[1] in ["port", "timeout", "maxdelay"]:
|
||||
try:
|
||||
spl[2] = int(spl[2])
|
||||
except:
|
||||
failure("Value must be an integer, not %s" % spl[2])
|
||||
return
|
||||
|
||||
if spl[2] in ["initialdelay", "factor", "jitter"]:
|
||||
try:
|
||||
spl[3] = float(spl[3])
|
||||
except:
|
||||
failure("Value must be a floating point integer, not %s" % spl[3])
|
||||
return
|
||||
|
||||
if spl[1] == "protocol":
|
||||
if not toUnset:
|
||||
if not spl[2] in ["ssl", "plain"]:
|
||||
|
@ -1108,13 +1122,20 @@ class Helper(object):
|
|||
spl[3] = None
|
||||
toUnset = True
|
||||
|
||||
if spl[2] in ["port", "timeout", "maxdelay", "initialdelay", "factor", "jitter"]:
|
||||
if spl[2] in ["port", "timeout", "maxdelay"]:
|
||||
try:
|
||||
spl[3] = int(spl[3])
|
||||
except:
|
||||
failure("Value must be an integer, not %s" % spl[3])
|
||||
return
|
||||
|
||||
if spl[2] in ["initialdelay", "factor", "jitter"]:
|
||||
try:
|
||||
spl[3] = float(spl[3])
|
||||
except:
|
||||
failure("Value must be a floating point integer, not %s" % spl[3])
|
||||
return
|
||||
|
||||
if spl[2] == "authtype":
|
||||
if not toUnset:
|
||||
if not spl[3] in ["sp", "ns"]:
|
||||
|
|
Loading…
Reference in New Issue