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
|
return servers
|
||||||
|
|
||||||
|
def _channel_stats(self, channel):
|
||||||
|
return {
|
||||||
|
"users": len(channel.users),
|
||||||
|
"topic": channel.topic
|
||||||
|
}
|
||||||
@utils.hook("api.channels")
|
@utils.hook("api.channels")
|
||||||
def channels_api(self, event):
|
def channels_api(self, event):
|
||||||
print(event["path"])
|
print(event["path"])
|
||||||
|
@ -74,12 +79,13 @@ class Module(ModuleManager.BaseModule):
|
||||||
return None
|
return None
|
||||||
channels = {}
|
channels = {}
|
||||||
for channel in server.channels.values():
|
for channel in server.channels.values():
|
||||||
channels[channel.name] = len(channel.users)
|
channels[channel.name] = self._channel_stats(channel)
|
||||||
return channels
|
return channels
|
||||||
else:
|
else:
|
||||||
channels = {}
|
channels = {}
|
||||||
for server in self.bot.servers.values():
|
for server in self.bot.servers.values():
|
||||||
channels[server.id] = {}
|
channels[server.id] = {}
|
||||||
for channel in server.channels.values():
|
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
|
return channels
|
||||||
|
|
Loading…
Reference in a new issue