Add helper to get all active relays

This commit is contained in:
Mark Veidemanis 2022-08-13 22:36:18 +01:00
parent 047e9148aa
commit 406b3d77f4
1 changed files with 16 additions and 0 deletions

View File

@ -33,3 +33,19 @@ def is_first_relay(net, num):
if not first_relay:
return False
return first_relay.num == num
def get_active_relays(net):
"""
Get all active instances for the network.
:param net: the network
:return: list of active instances
:rtype: list of IRCPool instances
"""
active_nums = chankeep.getActiveRelays(net)
active_insts = []
for num in active_nums:
name = net + str(num)
if name in main.IRCPool.keys():
active_insts.append(main.IRCPool[name])
return active_insts