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 128e005611
commit ed1f3cdca7
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 25 additions and 5 deletions

View File

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

View File

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