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 +++- server/src/commands/core/changenick.js | 6 +++- server/src/commands/core/chat.js | 6 +++- server/src/commands/core/disconnect.js | 5 +++- server/src/commands/core/help.js | 49 +++++++++++++++++++++++++++++++++ server/src/commands/core/invite.js | 6 +++- server/src/commands/core/join.js | 6 +++- server/src/commands/core/morestats.js | 5 +++- server/src/commands/core/move.js | 6 +++- server/src/commands/core/stats.js | 5 +++- server/src/commands/mod/ban.js | 6 +++- server/src/commands/mod/kick.js | 6 +++- server/src/commands/mod/unban.js | 6 +++- 17 files changed, 124 insertions(+), 16 deletions(-) create mode 100644 server/src/commands/core/help.js (limited to 'server') 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 diff --git a/server/src/commands/core/changenick.js b/server/src/commands/core/changenick.js index 94ae4d4..4041bb0 100644 --- a/server/src/commands/core/changenick.js +++ b/server/src/commands/core/changenick.js @@ -81,4 +81,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { name: 'changenick' }; +exports.info = { + name: 'changenick', + usage: 'changenick {nick}', + description: 'This will change your current connections nickname' +}; diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js index 36a98e8..bce6adb 100644 --- a/server/src/commands/core/chat.js +++ b/server/src/commands/core/chat.js @@ -55,4 +55,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['text']; -exports.info = { name: 'chat' }; +exports.info = { + name: 'chat', + usage: 'chat {text}', + description: 'Broadcasts passed `text` field to the calling users channel' +}; \ No newline at end of file diff --git a/server/src/commands/core/disconnect.js b/server/src/commands/core/disconnect.js index 9e733fa..9b54214 100644 --- a/server/src/commands/core/disconnect.js +++ b/server/src/commands/core/disconnect.js @@ -15,4 +15,7 @@ exports.run = async (core, server, socket, data) => { socket.terminate(); }; -exports.info = { name: 'disconnect' }; +exports.info = { + name: 'disconnect', + description: 'Event handler or force disconnect (if your into that kind of thing)' +}; \ No newline at end of file diff --git a/server/src/commands/core/help.js b/server/src/commands/core/help.js new file mode 100644 index 0000000..7f63d3d --- /dev/null +++ b/server/src/commands/core/help.js @@ -0,0 +1,49 @@ +/* + Description: Outputs the current command module list or command categories +*/ + +const stripIndents = require('common-tags').stripIndents; + +exports.run = async (core, server, socket, data) => { + // verify passed arguments + let typeDt = typeof data.type; + let catDt = typeof data.category; + let cmdDt = typeof data.command; + if (typeDt !== 'undefined' && typeDt !== 'string' ) { + return; + } else if (catDt !== 'undefined' && catDt !== 'string' ) { + return; + } else if (cmdDt !== 'undefined' && cmdDt !== 'string' ) { + return; + } + + // set default reply + let reply = stripIndents`Help usage: + Show all categories -> { cmd: 'help', type: 'categories' } + Show all commands in category -> { cmd: 'help', category: '' } + Show specific command -> { cmd: 'help', command: '' }`; + + if (typeDt !== 'undefined') { + let categories = core.commands.categories().sort(); + reply = `Command Categories:\n${categories.map(c => `- ${c.replace('../src/commands/', '')}`).join('\n')}`; + } else if (catDt !== 'undefined') { + let catCommands = core.commands.all('../src/commands/' + data.category).sort((a, b) => a.info.name.localeCompare(b.info.name)); + reply = `${data.category} commands:\n${catCommands.map(c => `- ${c.info.name}`).join('\n')}`; + } else if (cmdDt !== 'undefined') { + let command = core.commands.get(data.command); + reply = stripIndents` + Usage: ${command.info.usage || command.info.name} + Description: ${command.info.description || '¯\_(ツ)_/¯'}`; + } + + server.reply({ + cmd: 'info', + text: reply + }, socket); +}; + +exports.info = { + name: 'help', + usage: 'help ([ type:categories] | [category: | command: ])', + description: 'Outputs information about the servers current protocol' +}; \ No newline at end of file diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js index 3fbbe6e..bcf9097 100644 --- a/server/src/commands/core/invite.js +++ b/server/src/commands/core/invite.js @@ -58,4 +58,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { name: 'invite' }; +exports.info = { + name: 'invite', + usage: 'invite {nick}', + description: 'Generates a unique (more or less) room name and passes it to two clients' +}; \ No newline at end of file diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js index b72824b..f2b2c9d 100644 --- a/server/src/commands/core/join.js +++ b/server/src/commands/core/join.js @@ -128,4 +128,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['channel', 'nick']; -exports.info = { name: 'join' }; +exports.info = { + name: 'join', + usage: 'join {channel} {nick}', + description: 'Place calling socket into target channel with target nick & broadcast event to channel' +}; \ No newline at end of file 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 diff --git a/server/src/commands/core/move.js b/server/src/commands/core/move.js index 9462468..c5efafd 100644 --- a/server/src/commands/core/move.js +++ b/server/src/commands/core/move.js @@ -76,4 +76,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['channel']; -exports.info = { name: 'move' }; +exports.info = { + name: 'move', + usage: 'move {channel}', + description: 'This will change the current channel to the new one provided' +}; \ No newline at end of file diff --git a/server/src/commands/core/stats.js b/server/src/commands/core/stats.js index 2802579..b9dc002 100644 --- a/server/src/commands/core/stats.js +++ b/server/src/commands/core/stats.js @@ -26,4 +26,7 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.increment('stats-requested'); }; -exports.info = { name: 'stats' }; +exports.info = { + name: 'stats', + description: 'Sends back legacy server stats to the calling client' +}; \ No newline at end of file diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js index b2749ae..e19efc2 100644 --- a/server/src/commands/mod/ban.js +++ b/server/src/commands/mod/ban.js @@ -57,4 +57,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { name: 'ban' }; +exports.info = { + name: 'ban', + usage: 'ban {nick}', + description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter' +}; diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js index 5c72160..157592d 100644 --- a/server/src/commands/mod/kick.js +++ b/server/src/commands/mod/kick.js @@ -71,4 +71,8 @@ exports.run = async (core, server, socket, data) => { exports.requiredData = ['nick']; -exports.info = { name: 'kick' }; +exports.info = { + name: 'kick', + usage: 'kick {nick}', + description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings' +}; \ No newline at end of file diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js index 5450858..e82f0b9 100644 --- a/server/src/commands/mod/unban.js +++ b/server/src/commands/mod/unban.js @@ -48,4 +48,8 @@ exports.run = async (core, server, socket, data) => { core.managers.stats.decrement('users-banned'); }; -exports.info = { name: 'unban' }; +exports.info = { + name: 'unban', + usage: 'unban {[ip || hash]}', + description: 'Removes target ip from the ratelimiter' +}; \ No newline at end of file -- cgit v1.2.1