commands
NodeBB provider module User class
Author: Accalia
License: MIT
- commands
- static
- inner
- ~Command
- new Command(definition, parent)
- .line :
string
- .command :
string
- .commandText :
string
- .mention :
boolean
- .args :
Array.<string>
- .parent :
Commands
- .replyText :
string
- .executable :
boolean
- .execute() ⇒
Promise
- .getPost() ⇒
Promise.<Post>
- .getTopic() ⇒
Promise.<Topic>
- .getUser() ⇒
Promise.<User>
- .getPM() ⇒
Promise.<PrivateMessage>
- .reply(content)
- .appendReply(content)
- ~Commands
- new Commands(ids, postBody, handler)
- instance
- .ids :
Ids
- .commands :
Array.<Command>
- .text :
string
- .getPost() ⇒
Promise.<Post>
- .setPost(post)
- .getTopic() ⇒
Promise.<Topic>
- .setTopic(topic)
- .getPM() ⇒
Promise.<ChatRoom>
- .setPM(pm)
- .getUser() ⇒
Promise.<User>
- .setUser(user)
- .execute() ⇒
Promise.<Commands>
- .ids :
- static
- .get(notification, postBody, handler) ⇒
Promise.<Commands>
- .add(command, helpText, handler, [context]) ⇒
Promise
- .addAlias(command, handler, [context]) ⇒
Promise
- .addExtendedHelp(command, text) ⇒
Promise
- .forbidCommand(command) ⇒
boolean
- .get(notification, postBody, handler) ⇒
- ~Command
commands.bindCommands(forum) ⇒ Commands
Create a Commands class and bind it to a forum instance.
Kind: static method of commands
Returns: Commands
- A Commands class bound to the provided forum
instance
Param | Type | Description |
---|---|---|
forum | Provider |
A forum Provider instance to bind to constructed Commands class |
- .bindCommands(forum) ⇒
Commands
bindCommands~handlers
Command Handlers
Kind: inner constant of bindCommands
Default: {"help":""}
bindCommands~shadowHandlers
Shadow Command Handlers
Kind: inner constant of bindCommands
Default: {}
bindCommands~forbiddenCmds
Commands forbidden by the forum provider
Kind: inner constant of bindCommands
Default: {}
bindCommands~helpTopics
Extended help topics
Kind: inner constant of bindCommands
bindCommands~checkAvailable(map, command, logType, logMsg) ⇒ boolean
Check the availability of a command
Kind: inner method of bindCommands
Returns: boolean
- True if available, false otherwise
Param | Type | Description |
---|---|---|
map | object |
A map of commands to check availability against |
command | string |
Name of command to check |
logType | string |
Type of log to log if command isn't available |
logMsg | string |
Message to log if command is not available |
commands~Command
Command Class. Represents a single command within a post
Kind: inner class of commands
- ~Command
- new Command(definition, parent)
- .line :
string
- .command :
string
- .commandText :
string
- .mention :
boolean
- .args :
Array.<string>
- .parent :
Commands
- .replyText :
string
- .executable :
boolean
- .execute() ⇒
Promise
- .getPost() ⇒
Promise.<Post>
- .getTopic() ⇒
Promise.<Topic>
- .getUser() ⇒
Promise.<User>
- .getPM() ⇒
Promise.<PrivateMessage>
- .reply(content)
- .appendReply(content)
new Command(definition, parent)
Create a Command from a defintiton
Param | Type | Description |
---|---|---|
definition | object |
Parsed Command defintition |
parent | Commands |
Commands instnace that created this Command |
command.line : string
Full Command line definition
Kind: instance property of Command
Access: public
command.command : string
Normalized command name
Kind: instance property of Command
Access: public
command.commandText : string
Unnormalized command name
Kind: instance property of Command
Access: public
command.mention : boolean
Is Command a mention command?
Kind: instance property of Command
Access: public
command.args : Array.<string>
Command arguments
Kind: instance property of Command
Access: public
command.parent : Commands
Parent Commands object
Kind: instance property of Command
Access: public
command.replyText : string
Text to post as a reply to the command
Kind: instance property of Command
Access: public
command.executable : boolean
Indicates if this command will execute any handler
Kind: instance property of Command
Access: public
command.execute() ⇒ Promise
Execute the command handler for this command
Kind: instance method of Command
Returns: Promise
- Resolves when command has fully executed
Access: public
command.getPost() ⇒ Promise.<Post>
Get Full Post the command refers to
Kind: instance method of Command
Returns: Promise.<Post>
- Resolves to retrieved Post
Access: public
command.getTopic() ⇒ Promise.<Topic>
Get Topic command was posted to
Kind: instance method of Command
Returns: Promise.<Topic>
- Resolves to retrieved Topic
Access: public
command.getUser() ⇒ Promise.<User>
Get User who posted the command
Kind: instance method of Command
Returns: Promise.<User>
- Resolved to retrieved User
Access: public
command.getPM() ⇒ Promise.<PrivateMessage>
Get PrivateMessage who posted the command
Kind: instance method of Command
Returns: Promise.<PrivateMessage>
- Resolved to retrieved PrivateMessage
Access: public
command.reply(content)
Reply to command with content
Kind: instance method of Command
Access: public
Param | Type | Description |
---|---|---|
content | string |
Content to reply with |
command.appendReply(content)
Append content to the reply of command
Kind: instance method of Command
Access: public
Param | Type | Description |
---|---|---|
content | string |
Content to append to reply |
commands~Commands
Commands class. Represents all commands for a Notification
Kind: inner class of commands
Access: public
- ~Commands
- new Commands(ids, postBody, handler)
- instance
- .ids :
Ids
- .commands :
Array.<Command>
- .text :
string
- .getPost() ⇒
Promise.<Post>
- .setPost(post)
- .getTopic() ⇒
Promise.<Topic>
- .setTopic(topic)
- .getPM() ⇒
Promise.<ChatRoom>
- .setPM(pm)
- .getUser() ⇒
Promise.<User>
- .setUser(user)
- .execute() ⇒
Promise.<Commands>
- .ids :
- static
- .get(notification, postBody, handler) ⇒
Promise.<Commands>
- .add(command, helpText, handler, [context]) ⇒
Promise
- .addAlias(command, handler, [context]) ⇒
Promise
- .addExtendedHelp(command, text) ⇒
Promise
- .forbidCommand(command) ⇒
boolean
- .get(notification, postBody, handler) ⇒
new Commands(ids, postBody, handler)
Construct a Commands object from notification
Param | Type | Description |
---|---|---|
ids | Ids |
Useful Ids |
postBody | string |
Raw Content of post containing commands |
handler | ReplyHandler |
Reply handler |
commands.ids : Ids
Ids relevant to this Commands object
Kind: instance property of Commands
Access: public
commands.commands : Array.<Command>
Commands contained in this Commands object
Kind: instance property of Commands
Access: public
commands.text : string
Text this Commands object parsed
Kind: instance property of Commands
Access: public
commands.getPost() ⇒ Promise.<Post>
Get the Post this Commands object referrs to
Kind: instance method of Commands
Returns: Promise.<Post>
- Resolves to the retrieved Post
Access: public
commands.setPost(post)
Set the Post this Commands object refers to
Kind: instance method of Commands
Access: public
Param | Type | Description |
---|---|---|
post | Post |
The Post to cache |
commands.getTopic() ⇒ Promise.<Topic>
Get the Topic this Commands object referrs to
Kind: instance method of Commands
Returns: Promise.<Topic>
- Resolves to the retrieved Topic
Access: public
commands.setTopic(topic)
Set the Topic this Commands object refers to
Kind: instance method of Commands
Access: public
Param | Type | Description |
---|---|---|
topic | Topic |
The Topic to cache |
commands.getPM() ⇒ Promise.<ChatRoom>
Get the PrivateMessage this Commands object referrs to
Kind: instance method of Commands
Returns: Promise.<ChatRoom>
- Resolves to the retrieved ChatRoom
Access: public
commands.setPM(pm)
Set the PrivateMessage this Commands object refers to
Kind: instance method of Commands
Access: public
Param | Type | Description |
---|---|---|
pm | PrivateMessage |
The pm to cache |
commands.getUser() ⇒ Promise.<User>
Get the user who sent these commands
Kind: instance method of Commands
Returns: Promise.<User>
- Resolved to the retrieved User
Access: public
commands.setUser(user)
Set the User this Commands object refers to
Kind: instance method of Commands
Access: public
Param | Type | Description |
---|---|---|
user | User |
The User to cache |
commands.execute() ⇒ Promise.<Commands>
Execute the commands this object contains
Kind: instance method of Commands
Returns: Promise.<Commands>
- Resolves to self when all commands have been processed
Access: public
Commands.get(notification, postBody, handler) ⇒ Promise.<Commands>
Get Commands from a notification
Kind: static method of Commands
Returns: Promise.<Commands>
- Resolves to parsed commands
Access: public
Param | Type | Description |
---|---|---|
notification | Notification |
Notification to get commands for |
postBody | string |
Post Body to parse for commands |
handler | ReplyHandler |
Reply function for commands |
Commands.add(command, helpText, handler, [context]) ⇒ Promise
Add a command to this forum instance
Kind: static method of Commands
Returns: Promise
- Resolves when command has been added
Access: public
Param | Type | Description |
---|---|---|
command | string |
Command to be added |
helpText | string |
Short help text for command |
handler | CommandHandler |
Function to handle the command |
[context] | object |
this context for the command. If not provided context will be a bare Object. |
Commands.addAlias(command, handler, [context]) ⇒ Promise
Add a command alias to this forum instance
Kind: static method of Commands
Returns: Promise
- Resolves when command has been added
Access: public
Param | Type | Description |
---|---|---|
command | string |
Command alias to be added |
handler | CommandHandler |
Function to handle the command |
[context] | object |
this context for the command. If not provided context will be a bare Object. |
Commands.addExtendedHelp(command, text) ⇒ Promise
Add an extended help message for a command
Kind: static method of Commands
Returns: Promise
- Resolves when help message has been added
Param | Type | Description |
---|---|---|
command | string |
The command to add help text to |
text | string |
The help text to add for a command |
Commands.forbidCommand(command) ⇒ boolean
Forbid a command from being registered.
This is to allow a provider the ability to prevent commands from being registered or triggered that would be problematic or prone to being accidentally triggered on the target system.
Kind: static method of Commands
Returns: boolean
- True if the command was already forbidden, false otherwise.
Param | Type | Description |
---|---|---|
command | string |
The forbidden command |