1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00
Neel Kamath 2bb5ced363 Flatten
2018-05-13 16:09:55 +05:30

32 lines
768 B
JavaScript

/*
Description: Legacy stats output, kept for compatibility, outputs user and channel count
*/
exports.run = async (core, server, socket, data) => {
let ips = {};
let channels = {};
for (let client of server.clients) {
if (client.channel) {
channels[client.channel] = true;
ips[client.remoteAddress] = true;
}
}
let uniqueClientCount = Object.keys(ips).length;
let uniqueChannels = Object.keys(channels).length;
ips = null;
channels = null;
server.reply({
cmd: 'info',
text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels`
}, socket);
core.managers.stats.increment('stats-requested');
};
exports.info = {
name: 'stats',
description: 'Sends back legacy server stats to the calling client'
};