new Helper(scripts)
Creates a Helper instance
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
scripts |
botScript |
<repeatable> |
the script modules to load into the Bot |
Methods
-
<async> destroy()
-
Destroys the Bot.
Must be called when providing
truein thehttpdparameter when calling #initReturns:
- Type
- Promise.<void>
-
emit(event, args)
-
Emits the provided
eventin the BotParameters:
Name Type Argument Description eventstring argsstring <repeatable>
Returns:
null
-
<async> enter(user, room)
-
Triggers an EnterMessage at the provided
roomby the provideduserParameters:
Name Type Description userUser roomstring Returns:
- Type
- Promise.<void>
-
<async> init( [httpd])
-
Initializes the Bot and prepares everything needed to receive messages
When providing
trueinhttpd, #destroy must be called after the tests have completed.Parameters:
Name Type Argument Default Description httpdboolean <optional>
false Option to start an HTTP server for the Bot
Returns:
- Type
- Promise.<void>
-
<async> leave(user, room)
-
Triggers a LeaveMessage at the provided
roomby the provideduserParameters:
Name Type Description userUser roomstring Returns:
- Type
- Promise.<void>
-
messagesAt(room [, username])
-
Returns an array of arrays with: 0. The author's username
- The message
Parameters:
Name Type Argument Description roomstring usernamestring <optional>
filter returned messages by author's username
Returns:
- Type
- Array.<Array.<string>>
-
on(event, listener)
-
Sets up a listener that will be called whenever the provided
eventis emitted by the BotParameters:
Name Type Description eventstring listenerfunction Returns:
null
-
<async> sendMessage(user, room, message)
-
Sends a
messageby auserin aroomParameters:
Name Type Description userUser roomstring messagestring Returns:
- Type
- Promise.<void>
-
user(name [, alias])
-
Returns a new user that can interact with the Bot
Parameters:
Name Type Argument Default Description namestring aliasstring <optional>
null defaults to the provided name in low case
Returns:
- Type
- User