diff --git a/core/bot.py b/core/bot.py index df3345a..da355ee 100644 --- a/core/bot.py +++ b/core/bot.py @@ -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"]: diff --git a/modules/chankeep.py b/modules/chankeep.py index 68eab78..beef873 100644 --- a/modules/chankeep.py +++ b/modules/chankeep.py @@ -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: