From 2a2f24f57041ae84c86fbbcb84f6e713b990e527 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Fri, 26 Aug 2022 22:17:12 +0100 Subject: [PATCH] Fix getting first relay when they are not sequential --- modules/chankeep.py | 2 +- modules/helpers.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/chankeep.py b/modules/chankeep.py index 716b791..d4f1b39 100644 --- a/modules/chankeep.py +++ b/modules/chankeep.py @@ -138,7 +138,7 @@ def getActiveRelays(net): # ) if main.IRCPool[name].authenticated and main.IRCPool[name].isconnected: activeRelays.append(i) - # debug(f"getActiveRelays() {net}: {activeRelays}") + debug(f"getActiveRelays() {net}: {activeRelays}") return activeRelays diff --git a/modules/helpers.py b/modules/helpers.py index f2a8690..05d5bf2 100644 --- a/modules/helpers.py +++ b/modules/helpers.py @@ -1,7 +1,7 @@ import main from modules import chankeep -# from utils.logging.debug import debug +from utils.logging.debug import debug def get_first_relay(net): @@ -12,10 +12,11 @@ def get_first_relay(net): :return: IRCPool instance for the IRC bot """ cur_relay = 0 - max_relay = len(main.network[net].relays.keys()) + 1 - # debug(f"get_first_relay() {net}: max_relay:{max_relay}") + max_relay = max(main.network[net].relays.keys()) + debug(f"get_first_relay() {net}: max_relay:{max_relay}") activeRelays = chankeep.getActiveRelays(net) - # debug(f"get_first_relay() {net}: activeRelays:{activeRelays}") + + debug(f"get_first_relay() {net}: activeRelays:{activeRelays}") while cur_relay != max_relay: cur_relay += 1 if cur_relay not in activeRelays: