From 6cc07c91714018a3c344fa56c37d4057fbd891b2 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 14 Aug 2022 10:58:28 +0100 Subject: [PATCH] Add allRelaysActive output to network info --- api/views.py | 1 + core/bot.py | 2 +- modules/chankeep.py | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/views.py b/api/views.py index 788a0dc..842c186 100644 --- a/api/views.py +++ b/api/views.py @@ -187,6 +187,7 @@ class API(object): networks = {} for net in main.network.keys(): networks[net] = { + "active": chankeep.allRelaysActive(net), "relays": len(main.network[net].relays), "channels": userinfo.getTotalChanNum(net), "records": userinfo.getNumWhoEntries(net), diff --git a/core/bot.py b/core/bot.py index da355ee..cab516b 100644 --- a/core/bot.py +++ b/core/bot.py @@ -489,7 +489,7 @@ class IRCBot(IRCClient): if first_relay: if first_relay.wantList is True: first_relay.list(nocheck=True) - debug("recheckList() asking for a list for {self.net} after final relay {self.num} connected") + debug(f"recheckList() asking for a list for {self.net} after final relay {self.num} connected") else: debug(f"recheckList() first relay wantList is False for {self.net} ({first_relay.num})") # name = self.net + "1" diff --git a/modules/chankeep.py b/modules/chankeep.py index beef873..ef5a52d 100644 --- a/modules/chankeep.py +++ b/modules/chankeep.py @@ -62,6 +62,18 @@ def getActiveRelays(net): return activeRelays +def relayIsActive(net, num): + """ + Check if a relay is active. + :param net: network + :param num: relay number + :rtype: bool + :return: True if relay is active, False otherwise + """ + activeRelays = getActiveRelays(net) + return num in activeRelays + + def allRelaysActive(net): """ Check if all enabled relays are active and authenticated.