Implement getting number of channels and users
This commit is contained in:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user