Implement getting number of channels and users

This commit is contained in:
2022-07-21 13:40:18 +01:00
parent a8d0a7d886
commit 8c9ec3ab9c
2 changed files with 61 additions and 1 deletions

View File

@@ -23,7 +23,7 @@ def getWho(query):
def getChansSingle(name, nick):
nick = ["live.chan." + name + "." + i for i in nick]
nick = ("live.chan." + name + "." + i for i in nick)
result = main.r.sinter(*nick)
if len(result) == 0:
return None
@@ -38,6 +38,28 @@ def getChanList(name, nick):
return (i.decode() for i in result)
def getUserNum(name, channels):
"""
Get the number of users on a list of channels.
"""
chanspace = ("live.who." + name + "." + i for i in channels)
results = {}
for channel, space in zip(channels, chanspace):
results[channel] = main.r.scard(space)
return results
def getChanNum(name, nicks):
"""
Get the number of channels a list of users are on.
"""
nickspace = ("live.chan." + name + "." + i for i in nicks)
results = {}
for nick, space in zip(nicks, nickspace):
results[nick] = main.r.scard(space)
return results
def getChans(nick):
result = {}
for i in main.network.keys():