diff options
Diffstat (limited to 'server/src/commands/core')
-rw-r--r-- | server/src/commands/core/changenick.js | 6 | ||||
-rw-r--r-- | server/src/commands/core/chat.js | 6 | ||||
-rw-r--r-- | server/src/commands/core/disconnect.js | 5 | ||||
-rw-r--r-- | server/src/commands/core/help.js | 49 | ||||
-rw-r--r-- | server/src/commands/core/invite.js | 6 | ||||
-rw-r--r-- | server/src/commands/core/join.js | 6 | ||||
-rw-r--r-- | server/src/commands/core/morestats.js | 5 | ||||
-rw-r--r-- | server/src/commands/core/move.js | 6 | ||||
-rw-r--r-- | server/src/commands/core/stats.js | 5 |
9 files changed, 86 insertions, 8 deletions
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: '<category name>' } + Show specific command -> { cmd: 'help', command: '<command name>' }`; + + 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:<category name> | command:<command name> ])', + 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 |