Add debug statements and only check if network is connected when parting channels

This commit is contained in:
Mark Veidemanis 2022-08-14 09:25:54 +01:00
parent 9b14979f29
commit feecf48b9b
2 changed files with 25 additions and 5 deletions

View File

@ -620,22 +620,24 @@ class IRCBot(IRCClient):
return
sinst = regproc.substitute(self.net, self.num)
if not sinst:
error(f"Registration ping failed for {self.net} - {self.num}")
error(f"regPing() {self.net}: registration ping failed for {self.num}")
return
if self._negativePass is not True:
if negativepass is False:
self._negativePass = False
debug(f"regPing() {self.net}: negativepass is False for {self.num}")
return
if negativepass is True:
if self._negativePass is None:
self._negativePass = True
debug("Positive registration check - %s - %i" % (self.net, self.num))
debug(f"regPing() {self.net}: positive registration check - {self.num}")
if sinst["ping"]:
debug("Sending ping - %s - %i" % (self.net, self.num))
self.msg(sinst["entity"], sinst["pingmsg"])
debug(f"regPing() {self.net}: sent ping '{sinst['pingmsg']}' to {sinst['entity']} - {self.num}")
return
else:
debug("Negative registration for %s - %i" % (self.net, self.num))
debug("regPing() {self.net}: negative registration check - {self.num}")
return
if sinst["check"]:

View File

@ -20,12 +20,30 @@ def getEnabledRelays(net):
return enabledRelays
def getConnectedRelays(net):
"""
Get a list of connected relays for a network.
:param net: network
:rtype: list of int
:return: list of relay numbers
"""
enabledRelays = getEnabledRelays(net)
connectedRelays = []
for i in enabledRelays:
name = net + str(i)
if name in main.IRCPool.keys():
if main.IRCPool[name].isconnected:
connectedRelays.append(i)
debug(f"getConnectedRelays() {net}: {connectedRelays}")
return connectedRelays
def getActiveRelays(net):
"""
Get a list of active relays for a network.
:param net: network
:rtype: list of int
:return: list of getEnabledRelays relay numbers
:return: list of relay numbers
"""
enabledRelays = getEnabledRelays(net)
activeRelays = []
@ -321,7 +339,7 @@ def partSingle(net, channel):
:rtype: list of str
"""
parted = []
for i in getActiveRelays(net):
for i in getConnectedRelays(net):
name = f"{net}{i}"
if name in main.IRCPool.keys():
if channel in main.IRCPool[name].channels: