Provide more information for api.channels
This commit is contained in:
parent
d7f4050ae8
commit
52b7beb407
1 changed files with 8 additions and 2 deletions
|
@ -60,6 +60,11 @@ class Module(ModuleManager.BaseModule):
|
|||
}
|
||||
return servers
|
||||
|
||||
def _channel_stats(self, channel):
|
||||
return {
|
||||
"users": len(channel.users),
|
||||
"topic": channel.topic
|
||||
}
|
||||
@utils.hook("api.channels")
|
||||
def channels_api(self, event):
|
||||
print(event["path"])
|
||||
|
@ -74,12 +79,13 @@ class Module(ModuleManager.BaseModule):
|
|||
return None
|
||||
channels = {}
|
||||
for channel in server.channels.values():
|
||||
channels[channel.name] = len(channel.users)
|
||||
channels[channel.name] = self._channel_stats(channel)
|
||||
return channels
|
||||
else:
|
||||
channels = {}
|
||||
for server in self.bot.servers.values():
|
||||
channels[server.id] = {}
|
||||
for channel in server.channels.values():
|
||||
channels[server.id][str(channel)] = len(channel.users)
|
||||
channels[server.id][str(channel)] = self._channel_stats(
|
||||
channel)
|
||||
return channels
|
||||
|
|
Loading…
Reference in a new issue