From 73e5c5ccfe408e58eb4bb927c71a77e0fceb22c4 Mon Sep 17 00:00:00 2001 From: neelkamath Date: Fri, 11 May 2018 20:46:12 +0530 Subject: Remove forgettable, unused, occasionally harmful (w.r.t. ES6) directive --- server/src/commands/core/morestats.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'server/src/commands/core/morestats.js') diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js index d8bc23d..c1105f1 100644 --- a/server/src/commands/core/morestats.js +++ b/server/src/commands/core/morestats.js @@ -2,8 +2,6 @@ Description: Outputs more info than the legacy stats command */ -'use strict'; - const stripIndents = require('common-tags').stripIndents; const formatTime = (time) => { -- cgit v1.2.1 From acbad15f2bc4a6733407bc17e1a5b4190ed3b287 Mon Sep 17 00:00:00 2001 From: neelkamath Date: Sat, 12 May 2018 14:13:12 +0530 Subject: Remove unused object fields --- server/src/commands/core/morestats.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'server/src/commands/core/morestats.js') diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js index c1105f1..ce0e87d 100644 --- a/server/src/commands/core/morestats.js +++ b/server/src/commands/core/morestats.js @@ -47,7 +47,4 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.increment('stats-requested'); }; -exports.info = { - name: 'morestats', - description: 'Sends back current server stats to the calling client' -}; +exports.info = { name: 'morestats' }; -- cgit v1.2.1 From 343157350f627b9495184246a90033a1c41f1a2c Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Sun, 13 May 2018 16:03:22 +0530 Subject: Re-add module documentation --- server/src/commands/core/morestats.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'server/src/commands/core/morestats.js') diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js index ce0e87d..5510cb1 100644 --- a/server/src/commands/core/morestats.js +++ b/server/src/commands/core/morestats.js @@ -47,4 +47,7 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.increment('stats-requested'); }; -exports.info = { name: 'morestats' }; +exports.info = { + name: 'morestats', + description: 'Sends back current server stats to the calling client' +}; \ No newline at end of file -- cgit v1.2.1 From 2bb5ced363b692a5696b176bc317fe525c0c05df Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Sun, 13 May 2018 16:09:55 +0530 Subject: Flatten --- server/src/commands/core/morestats.js | 53 ----------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 server/src/commands/core/morestats.js (limited to 'server/src/commands/core/morestats.js') diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js deleted file mode 100644 index 5510cb1..0000000 --- a/server/src/commands/core/morestats.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - Description: Outputs more info than the legacy stats command -*/ - -const stripIndents = require('common-tags').stripIndents; - -const formatTime = (time) => { - let seconds = time[0] + time[1] / 1e9; - - let minutes = Math.floor(seconds / 60); - seconds = seconds % 60; - - let hours = Math.floor(minutes / 60); - minutes = minutes % 60; - return `${hours.toFixed(0)}h ${minutes.toFixed(0)}m ${seconds.toFixed(0)}s`; -}; - -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: stripIndents`current-connections: ${uniqueClientCount} - current-channels: ${uniqueChannels} - users-joined: ${(core.managers.stats.get('users-joined') || 0)} - invites-sent: ${(core.managers.stats.get('invites-sent') || 0)} - messages-sent: ${(core.managers.stats.get('messages-sent') || 0)} - users-banned: ${(core.managers.stats.get('users-banned') || 0)} - users-kicked: ${(core.managers.stats.get('users-kicked') || 0)} - stats-requested: ${(core.managers.stats.get('stats-requested') || 0)} - server-uptime: ${formatTime(process.hrtime(core.managers.stats.get('start-time')))}` - }, socket); - - core.managers.stats.increment('stats-requested'); -}; - -exports.info = { - name: 'morestats', - description: 'Sends back current server stats to the calling client' -}; \ No newline at end of file -- cgit v1.2.1 From 949404cd1aad8492ae0338130f16054adfa38ab7 Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Sun, 13 May 2018 16:37:56 +0530 Subject: Prevent fucking shit up --- server/src/commands/core/morestats.js | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 server/src/commands/core/morestats.js (limited to 'server/src/commands/core/morestats.js') diff --git a/server/src/commands/core/morestats.js b/server/src/commands/core/morestats.js new file mode 100644 index 0000000..5510cb1 --- /dev/null +++ b/server/src/commands/core/morestats.js @@ -0,0 +1,53 @@ +/* + Description: Outputs more info than the legacy stats command +*/ + +const stripIndents = require('common-tags').stripIndents; + +const formatTime = (time) => { + let seconds = time[0] + time[1] / 1e9; + + let minutes = Math.floor(seconds / 60); + seconds = seconds % 60; + + let hours = Math.floor(minutes / 60); + minutes = minutes % 60; + return `${hours.toFixed(0)}h ${minutes.toFixed(0)}m ${seconds.toFixed(0)}s`; +}; + +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: stripIndents`current-connections: ${uniqueClientCount} + current-channels: ${uniqueChannels} + users-joined: ${(core.managers.stats.get('users-joined') || 0)} + invites-sent: ${(core.managers.stats.get('invites-sent') || 0)} + messages-sent: ${(core.managers.stats.get('messages-sent') || 0)} + users-banned: ${(core.managers.stats.get('users-banned') || 0)} + users-kicked: ${(core.managers.stats.get('users-kicked') || 0)} + stats-requested: ${(core.managers.stats.get('stats-requested') || 0)} + server-uptime: ${formatTime(process.hrtime(core.managers.stats.get('start-time')))}` + }, socket); + + core.managers.stats.increment('stats-requested'); +}; + +exports.info = { + name: 'morestats', + description: 'Sends back current server stats to the calling client' +}; \ No newline at end of file -- cgit v1.2.1