commands

Command Parser for SockBot2.0

Author: Accalia
License: MIT

commands.prepare(events, callback)

Perpare the command parser

Needs to be called to set the internals of the parser after reading config file.

Kind: static method of commands

Param Type Description
events EventEmitter EventEmitter that will be core comms for SockBot
callback completedCallback Completion callback

commands.start()

Start the command parser after bot login

Kind: static method of commands

commands.parseCommands(post, topic, callback)

Parse commands from post and emit command events

Kind: static method of commands

Param Type Description
post external.posts.CleanedPost Post to parse commands from
topic external.topics.Topic Topic comamnd belongs to
callback parseCallback CompletionCallback

commands~parseShortCommand(line) ⇒ command

Parse a short command from input line

Kind: inner method of commands
Returns: command - Parsed command

Param Type Description
line string Input line to parse

commands~parseMentionCommand(line) ⇒ command

Parse a mention command from input line

Kind: inner method of commands
Returns: command - Parsed command

Param Type Description
line string Input line to parse

commands~getCommandHelps() ⇒ string

Get a list of commands that are registered withg the bot

Kind: inner method of commands
Returns: string - command list for posting

commands~cmdError(command)

Replies on unhandled command with helptext

Kind: inner method of commands

Param Type Description
command command Unhandled command

commands~cmdHelp(command)

Reply with help test top the command !help

Kind: inner method of commands

Param Type Description
command command help command

commands~registerCommand(command, helpstring, handler, callback) ⇒ undefined

Register a command

will be added to core EventEmitter as .onCommand()

Kind: inner method of commands
Returns: undefined - No return value

Param Type Description
command string Command to handle
helpstring string One line helpstring describing command
handler commandHandler Function to handle the command
callback completedCallback Completion callback

commands~commandProtect(event, handler) ⇒ boolean

Watch for unauthorized commands and reject them

Kind: inner method of commands
Returns: boolean - Flag wether event was of intrest to function

Param Type Description
event string Event that is registered
handler function Event Handler

commands~command : object

Parsed Command Data

Kind: inner typedef of commands

Param Type Description
input string Raw Command Input
command string Command name
args Array.<string> Command arguments
mention string Mention text that was included in command
post external.posts.CleanedPost Post that triggered the command

commands~completedCallback

Completion Callback

Kind: inner typedef of commands

Param Type Default Description
[err] Exception Error encountered processing request

commands~parseCallback

Parse Completion Callback

Kind: inner typedef of commands

Param Type Default Description
[err] Exception Error encountered processing request
commands Array.<command> Parsed Commands

commands~commandHandler

Command handler

Kind: inner typedef of commands

Param Type Description
command command Command to handle