1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00
hack-chat-main/server/src/commands/core/stats.js

32 lines
768 B
JavaScript
Raw Normal View History

2018-03-10 15:47:00 +08:00
/*
Description: Legacy stats output, kept for compatibility, outputs user and channel count
2018-03-10 15:47:00 +08:00
*/
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`
2018-03-10 15:47:00 +08:00
}, socket);
core.managers.stats.increment('stats-requested');
};
2018-05-13 18:33:22 +08:00
exports.info = {
name: 'stats',
description: 'Sends back legacy server stats to the calling client'
};