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/admin/addmod.js | 2 -- server/src/commands/admin/listusers.js | 2 -- server/src/commands/admin/reload.js | 2 -- server/src/commands/admin/saveconfig.js | 2 -- server/src/commands/admin/shout.js | 2 -- 5 files changed, 10 deletions(-) (limited to 'server/src/commands/admin') diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js index e9dde2c..4c13b22 100644 --- a/server/src/commands/admin/addmod.js +++ b/server/src/commands/admin/addmod.js @@ -2,8 +2,6 @@ Description: Adds the target trip to the mod list then elevates the uType */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js index 226b000..a539a3c 100644 --- a/server/src/commands/admin/listusers.js +++ b/server/src/commands/admin/listusers.js @@ -2,8 +2,6 @@ Description: Outputs all current channels and their user nicks */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js index 387ae97..4e22a95 100644 --- a/server/src/commands/admin/reload.js +++ b/server/src/commands/admin/reload.js @@ -2,8 +2,6 @@ Description: Clears and resets the command modules, outputting any errors */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js index 0c4e0c9..ed3a312 100644 --- a/server/src/commands/admin/saveconfig.js +++ b/server/src/commands/admin/saveconfig.js @@ -2,8 +2,6 @@ Description: Writes any changes to the config to the disk */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js index 736134a..4ebf696 100644 --- a/server/src/commands/admin/shout.js +++ b/server/src/commands/admin/shout.js @@ -2,8 +2,6 @@ Description: Emmits a server-wide message as `info` */ -'use strict'; - exports.run = async (core, server, socket, data) => { if (socket.uType != 'admin') { // ignore if not admin -- 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/admin/addmod.js | 6 +----- server/src/commands/admin/listusers.js | 5 +---- server/src/commands/admin/reload.js | 5 +---- server/src/commands/admin/saveconfig.js | 5 +---- server/src/commands/admin/shout.js | 6 +----- 5 files changed, 5 insertions(+), 22 deletions(-) (limited to 'server/src/commands/admin') diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js index 4c13b22..992f9c4 100644 --- a/server/src/commands/admin/addmod.js +++ b/server/src/commands/admin/addmod.js @@ -40,8 +40,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['trip']; -exports.info = { - name: 'addmod', - usage: 'addmod {trip}', - description: 'Adds target trip to the config as a mod and upgrades the socket type' -}; +exports.info = { name: 'addmod' }; diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js index a539a3c..92fa998 100644 --- a/server/src/commands/admin/listusers.js +++ b/server/src/commands/admin/listusers.js @@ -32,7 +32,4 @@ exports.run = async (core, server, socket, data) => { }, socket); }; -exports.info = { - name: 'listusers', - description: 'Outputs all current channels and sockets in those channels' -}; +exports.info = { name: 'listusers' }; diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js index 4e22a95..40de059 100644 --- a/server/src/commands/admin/reload.js +++ b/server/src/commands/admin/reload.js @@ -28,7 +28,4 @@ exports.run = async (core, server, socket, data) => { }, { uType: 'mod' }); }; -exports.info = { - name: 'reload', - description: '(Re)loads any new commands into memory, outputs errors if any' -}; +exports.info = { name: 'reload' }; diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js index ed3a312..116abd6 100644 --- a/server/src/commands/admin/saveconfig.js +++ b/server/src/commands/admin/saveconfig.js @@ -30,7 +30,4 @@ exports.run = async (core, server, socket, data) => { }, { uType: 'mod' }); }; -exports.info = { - name: 'saveconfig', - description: 'Saves current config' -}; +exports.info = { name: 'saveconfig' }; diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js index 4ebf696..2efff32 100644 --- a/server/src/commands/admin/shout.js +++ b/server/src/commands/admin/shout.js @@ -16,8 +16,4 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['text']; -exports.info = { - name: 'shout', - usage: 'shout {text}', - description: 'Displays passed text to every client connected' -}; +exports.info = { name: 'shout' }; -- 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/admin/addmod.js | 6 +++++- server/src/commands/admin/listusers.js | 5 ++++- server/src/commands/admin/reload.js | 6 +++++- server/src/commands/admin/saveconfig.js | 5 ++++- server/src/commands/admin/shout.js | 6 +++++- 5 files changed, 23 insertions(+), 5 deletions(-) (limited to 'server/src/commands/admin') diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js index 992f9c4..4c13b22 100644 --- a/server/src/commands/admin/addmod.js +++ b/server/src/commands/admin/addmod.js @@ -40,4 +40,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['trip']; -exports.info = { name: 'addmod' }; +exports.info = { + name: 'addmod', + usage: 'addmod {trip}', + description: 'Adds target trip to the config as a mod and upgrades the socket type' +}; diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js index 92fa998..a539a3c 100644 --- a/server/src/commands/admin/listusers.js +++ b/server/src/commands/admin/listusers.js @@ -32,4 +32,7 @@ exports.run = async (core, server, socket, data) => { }, socket); }; -exports.info = { name: 'listusers' }; +exports.info = { + name: 'listusers', + description: 'Outputs all current channels and sockets in those channels' +}; diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js index 40de059..e2cfbe6 100644 --- a/server/src/commands/admin/reload.js +++ b/server/src/commands/admin/reload.js @@ -28,4 +28,8 @@ exports.run = async (core, server, socket, data) => { }, { uType: 'mod' }); }; -exports.info = { name: 'reload' }; +exports.info = { + name: 'reload', + description: '(Re)loads any new commands into memory, outputs errors if any' +}; + diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js index 116abd6..ed3a312 100644 --- a/server/src/commands/admin/saveconfig.js +++ b/server/src/commands/admin/saveconfig.js @@ -30,4 +30,7 @@ exports.run = async (core, server, socket, data) => { }, { uType: 'mod' }); }; -exports.info = { name: 'saveconfig' }; +exports.info = { + name: 'saveconfig', + description: 'Saves current config' +}; diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js index 2efff32..1358dd9 100644 --- a/server/src/commands/admin/shout.js +++ b/server/src/commands/admin/shout.js @@ -16,4 +16,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['text']; -exports.info = { name: 'shout' }; +exports.info = { + name: 'shout', + usage: 'shout {text}', + description: 'Displays passed text to every client connected' +}; \ 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/admin/addmod.js | 47 --------------------------------- server/src/commands/admin/listusers.js | 38 -------------------------- server/src/commands/admin/reload.js | 35 ------------------------ server/src/commands/admin/saveconfig.js | 36 ------------------------- server/src/commands/admin/shout.js | 23 ---------------- 5 files changed, 179 deletions(-) delete mode 100644 server/src/commands/admin/addmod.js delete mode 100644 server/src/commands/admin/listusers.js delete mode 100644 server/src/commands/admin/reload.js delete mode 100644 server/src/commands/admin/saveconfig.js delete mode 100644 server/src/commands/admin/shout.js (limited to 'server/src/commands/admin') diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js deleted file mode 100644 index 4c13b22..0000000 --- a/server/src/commands/admin/addmod.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - Description: Adds the target trip to the mod list then elevates the uType -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let mod = { - trip: data.trip - } - - core.config.mods.push(mod); // purposely not using `config.set()` to avoid auto-save - - let newMod = server.findSockets({ trip: data.trip }); - - if (newMod.length !== 0) { - for (let i = 0, l = newMod.length; i < l; i++) { - newMod[i].uType = 'mod'; - - server.send({ - cmd: 'info', - text: 'You are now a mod.' - }, newMod[i]); - } - } - - server.reply({ - cmd: 'info', - text: `Added mod trip: ${data.trip}` - }, socket); - - server.broadcast({ - cmd: 'info', - text: `Added mod trip: ${data.trip}` - }, { uType: 'mod' }); -}; - -exports.requiredData = ['trip']; - -exports.info = { - name: 'addmod', - usage: 'addmod {trip}', - description: 'Adds target trip to the config as a mod and upgrades the socket type' -}; diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js deleted file mode 100644 index a539a3c..0000000 --- a/server/src/commands/admin/listusers.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - Description: Outputs all current channels and their user nicks -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let channels = {}; - for (var client of server.clients) { - if (client.channel) { - if (!channels[client.channel]) { - channels[client.channel] = []; - } - channels[client.channel].push(client.nick); - } - } - - let lines = []; - for (let channel in channels) { - lines.push(`?${channel} ${channels[channel].join(", ")}`); - } - - let text = ''; - text += lines.join("\n"); - - server.reply({ - cmd: 'info', - text: text - }, socket); -}; - -exports.info = { - name: 'listusers', - description: 'Outputs all current channels and sockets in those channels' -}; diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js deleted file mode 100644 index e2cfbe6..0000000 --- a/server/src/commands/admin/reload.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - Description: Clears and resets the command modules, outputting any errors -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let loadResult = core.managers.dynamicImports.reloadDirCache('src/commands'); - loadResult += core.commands.loadCommands(); - - if (loadResult == '') { - loadResult = `Loaded ${core.commands._commands.length} commands, 0 errors`; - } else { - loadResult = `Loaded ${core.commands._commands.length} commands, error(s): ${loadResult}`; - } - - server.reply({ - cmd: 'info', - text: loadResult - }, socket); - - server.broadcast({ - cmd: 'info', - text: loadResult - }, { uType: 'mod' }); -}; - -exports.info = { - name: 'reload', - description: '(Re)loads any new commands into memory, outputs errors if any' -}; - diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js deleted file mode 100644 index ed3a312..0000000 --- a/server/src/commands/admin/saveconfig.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - Description: Writes any changes to the config to the disk -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - let saveResult = core.managers.config.save(); - - if (!saveResult) { - server.reply({ - cmd: 'warn', - text: 'Failed to save config, check logs.' - }, client); - - return; - } - - server.reply({ - cmd: 'info', - text: 'Config saved!' - }, socket); - - server.broadcast({ - cmd: 'info', - text: 'Config saved!' - }, { uType: 'mod' }); -}; - -exports.info = { - name: 'saveconfig', - description: 'Saves current config' -}; diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js deleted file mode 100644 index 1358dd9..0000000 --- a/server/src/commands/admin/shout.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - Description: Emmits a server-wide message as `info` -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType != 'admin') { - // ignore if not admin - return; - } - - server.broadcast( { - cmd: 'info', - text: `Server Notice: ${data.text}` - }, {}); -}; - -exports.requiredData = ['text']; - -exports.info = { - name: 'shout', - usage: 'shout {text}', - description: 'Displays passed text to every client connected' -}; \ 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/admin/addmod.js | 47 +++++++++++++++++++++++++++++++++ server/src/commands/admin/listusers.js | 38 ++++++++++++++++++++++++++ server/src/commands/admin/reload.js | 35 ++++++++++++++++++++++++ server/src/commands/admin/saveconfig.js | 36 +++++++++++++++++++++++++ server/src/commands/admin/shout.js | 23 ++++++++++++++++ 5 files changed, 179 insertions(+) create mode 100644 server/src/commands/admin/addmod.js create mode 100644 server/src/commands/admin/listusers.js create mode 100644 server/src/commands/admin/reload.js create mode 100644 server/src/commands/admin/saveconfig.js create mode 100644 server/src/commands/admin/shout.js (limited to 'server/src/commands/admin') diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js new file mode 100644 index 0000000..4c13b22 --- /dev/null +++ b/server/src/commands/admin/addmod.js @@ -0,0 +1,47 @@ +/* + Description: Adds the target trip to the mod list then elevates the uType +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let mod = { + trip: data.trip + } + + core.config.mods.push(mod); // purposely not using `config.set()` to avoid auto-save + + let newMod = server.findSockets({ trip: data.trip }); + + if (newMod.length !== 0) { + for (let i = 0, l = newMod.length; i < l; i++) { + newMod[i].uType = 'mod'; + + server.send({ + cmd: 'info', + text: 'You are now a mod.' + }, newMod[i]); + } + } + + server.reply({ + cmd: 'info', + text: `Added mod trip: ${data.trip}` + }, socket); + + server.broadcast({ + cmd: 'info', + text: `Added mod trip: ${data.trip}` + }, { uType: 'mod' }); +}; + +exports.requiredData = ['trip']; + +exports.info = { + name: 'addmod', + usage: 'addmod {trip}', + description: 'Adds target trip to the config as a mod and upgrades the socket type' +}; diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js new file mode 100644 index 0000000..a539a3c --- /dev/null +++ b/server/src/commands/admin/listusers.js @@ -0,0 +1,38 @@ +/* + Description: Outputs all current channels and their user nicks +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let channels = {}; + for (var client of server.clients) { + if (client.channel) { + if (!channels[client.channel]) { + channels[client.channel] = []; + } + channels[client.channel].push(client.nick); + } + } + + let lines = []; + for (let channel in channels) { + lines.push(`?${channel} ${channels[channel].join(", ")}`); + } + + let text = ''; + text += lines.join("\n"); + + server.reply({ + cmd: 'info', + text: text + }, socket); +}; + +exports.info = { + name: 'listusers', + description: 'Outputs all current channels and sockets in those channels' +}; diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js new file mode 100644 index 0000000..e2cfbe6 --- /dev/null +++ b/server/src/commands/admin/reload.js @@ -0,0 +1,35 @@ +/* + Description: Clears and resets the command modules, outputting any errors +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let loadResult = core.managers.dynamicImports.reloadDirCache('src/commands'); + loadResult += core.commands.loadCommands(); + + if (loadResult == '') { + loadResult = `Loaded ${core.commands._commands.length} commands, 0 errors`; + } else { + loadResult = `Loaded ${core.commands._commands.length} commands, error(s): ${loadResult}`; + } + + server.reply({ + cmd: 'info', + text: loadResult + }, socket); + + server.broadcast({ + cmd: 'info', + text: loadResult + }, { uType: 'mod' }); +}; + +exports.info = { + name: 'reload', + description: '(Re)loads any new commands into memory, outputs errors if any' +}; + diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js new file mode 100644 index 0000000..ed3a312 --- /dev/null +++ b/server/src/commands/admin/saveconfig.js @@ -0,0 +1,36 @@ +/* + Description: Writes any changes to the config to the disk +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + let saveResult = core.managers.config.save(); + + if (!saveResult) { + server.reply({ + cmd: 'warn', + text: 'Failed to save config, check logs.' + }, client); + + return; + } + + server.reply({ + cmd: 'info', + text: 'Config saved!' + }, socket); + + server.broadcast({ + cmd: 'info', + text: 'Config saved!' + }, { uType: 'mod' }); +}; + +exports.info = { + name: 'saveconfig', + description: 'Saves current config' +}; diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js new file mode 100644 index 0000000..1358dd9 --- /dev/null +++ b/server/src/commands/admin/shout.js @@ -0,0 +1,23 @@ +/* + Description: Emmits a server-wide message as `info` +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType != 'admin') { + // ignore if not admin + return; + } + + server.broadcast( { + cmd: 'info', + text: `Server Notice: ${data.text}` + }, {}); +}; + +exports.requiredData = ['text']; + +exports.info = { + name: 'shout', + usage: 'shout {text}', + description: 'Displays passed text to every client connected' +}; \ No newline at end of file -- cgit v1.2.1