- Api
Api module connects to the backend api and provides low level methods for service modules to send and receive data.
- ActionCreateChar
ActionCreateChar adds the action to create a character if the limit is not reached.
- ActionGo
ActionGo adds the action to go around using exits.
- ActionIdle
ActionIdle adds the action to idle with awake characters.
- ActionLurk
ActionLurk adds the action to lurk for a while, without having any awake characters.
- ActionPose
ActionPose adds the action to pose in a room with other characters.
- ActionSay
ActionSay adds the action to speak in a room with other characters.
- ActionSleep
ActionSleep adds the action to put a character to sleep.
- ActionTeleport
ActionTeleport adds the action to teleport.
- ActionWakeup
ActionWakeup adds the action to wake up an existing character.
- ActionWhisper
ActionWhisper adds the action to speak in a room with other characters.
- BotController
BotController is the central module for creating an autonomous, self acting bot. Other modules may register actions that the bot controller may tell the bot-characters to perform.
- Personality
Personality holds common personality traits that an action can use to determine behavior.
- ReactionArriveWelcome
ReactionArriveWelcome greets when traveling to a room with other characters.
- ReactionRead
ReactionRead intercepts with idle time to read whenever someone else speaks in the room.
- ReactionTravelGreet
ReactionTravelGreet greets when traveling to a room with other characters.
- ReactionPrivateReply
ReactionPrivateReply reacts to whispers and enqueues a whisper reply.
- CharEvents
CharEvents listens to outgoing log events for any controlled character.
The purpose is to simplify listening and reacting to events for other modules.
- CharPing
CharPing periodically sends a ping for all controlled characters to ensure they are kept awake.
If the botController module is available, it will only ping characters validated by botController.validChar
- Login
Login logs in the bot after registering it.
- Player
Player fetches the player object and keeps it suscribed once logged in.
Api module connects to the backend api and provides low level methods for service modules to send and receive data.
Kind: global class
- Api
- .connect() ⇒
Promise
- .disconnect()
- .get(rid, [collectionFactory]) ⇒
Promise.<(ResModel|ResCollection)>
- .call(rid, method, params) ⇒
Promise.<object>
- .authenticate(rid, method, params) ⇒
Promise.<object>
- .setOnConnect(onConnect) ⇒
this
- .connect() ⇒
Connects the instance to the server. Can be called even if a connection is already established.
Kind: instance method of Api
Returns: Promise
- A promise to the established connection.
Disconnects any current connection and stops attempts of reconnecting.
Kind: instance method of Api
Get a resource from the API
Kind: instance method of Api
Returns: Promise.<(ResModel|ResCollection)>
- Promise of the resource.
Param | Type | Description |
---|---|---|
rid | string |
Resource ID |
[collectionFactory] | function |
Collection factory function. |
Calls a method on a resource.
Kind: instance method of Api
Returns: Promise.<object>
- Promise of the call result.
Param | Type | Description |
---|---|---|
rid | string |
Resource ID. |
method | string |
Method name |
params | * |
Method parameters |
Invokes a authentication method on a resource.
Kind: instance method of Api
Returns: Promise.<object>
- Promise of the authentication result.
Param | Type | Description |
---|---|---|
rid | string |
Resource ID. |
method | string |
Method name |
params | * |
Method parameters |
Sets the onConnect callback.
Kind: instance method of Api
Param | Type | Description |
---|---|---|
onConnect | ResClient~onConnectCallback |
On connect callback called prior resolving the connect promise and subscribing to stale resources. May return a promise. |
ActionCreateChar adds the action to create a character if the limit is not reached.
Kind: global class
Creates a new ActionCreateChar instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ActionCreateChar parameters.
Kind: inner typedef of ActionCreateChar
Properties
Name | Type | Description |
---|---|---|
[charLimit] | number |
Limit on how many characters are totally created. |
[probability] | number |
Probability of the action to occur. |
[delay] | number |
Delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
ActionGo adds the action to go around using exits.
Kind: global class
- ActionGo
- new ActionGo(app, params)
- ~Params :
Object
Creates a new ActionGo instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ActionGo parameters.
Kind: inner typedef of ActionGo
Properties
Name | Type | Description |
---|---|---|
[populationProbability] | object |
Probabilities of the action to occur based on room population. |
[delay] | number |
Delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
ActionIdle adds the action to idle with awake characters.
Kind: global class
- ActionIdle
- new ActionIdle(app, params)
- ~Params :
Object
Creates a new ActionIdle instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ActionIdle parameters.
Kind: inner typedef of ActionIdle
Properties
Name | Type | Description |
---|---|---|
[probability] | number |
Probability of the action to occur. |
[delayMin] | number |
Minimum time in milliseconds to idle. |
[delayMax] | number |
Maximum time in milliseconds to idle. |
[spread] | string |
How the random values are spread. May be 'linear', 'cube' (less high values), or 'square' (even less high values). |
ActionLurk adds the action to lurk for a while, without having any awake characters.
Kind: global class
- ActionLurk
- new ActionLurk(app, params)
- ~Params :
Object
Creates a new ActionLurk instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ActionLurk parameters.
Kind: inner typedef of ActionLurk
Properties
Name | Type | Description |
---|---|---|
[probability] | number |
Probability of the action to occur. |
[delayMin] | number |
Minimum time in milliseconds to lurk. |
[delayMax] | number |
Maximum time in milliseconds to lurk. |
ActionPose adds the action to pose in a room with other characters.
Kind: global class
- ActionPose
- new ActionPose(app, params)
- instance
- inner
- ~Params :
Object
- ~Params :
Creates a new ActionPose instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
Enqueues a pose action to the botController.
Kind: instance method of ActionPose
Param | Type | Description |
---|---|---|
charId | string |
Character ID. |
msg | string |
Message to pose. |
priority | number |
Priority of the action. |
ActionPose parameters.
Kind: inner typedef of ActionPose
Properties
Name | Type | Description |
---|---|---|
[populationProbability] | object |
Probabilities of the action to occur based on room population. |
[delay] | number |
Additional delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
[wordLengthMin] | number |
Minimum number of words in a message. Ignored if phrases is set. |
[wordLengthMax] | number |
Maximum number of words in a message. Ignored if phrases is set. |
[phrases] | Array.<string> |
An array of phrases to use as message. Null means random lorem ipsum. |
ActionSay adds the action to speak in a room with other characters.
Kind: global class
- ActionSay
- new ActionSay(app, params)
- instance
- inner
- ~Params :
Object
- ~Params :
Creates a new ActionSay instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
Enqueues a say action to the botController.
Kind: instance method of ActionSay
Param | Type | Description |
---|---|---|
charId | string |
Character ID. |
msg | string |
Message to say. |
priority | number |
Priority of the action. |
ActionSay parameters.
Kind: inner typedef of ActionSay
Properties
Name | Type | Description |
---|---|---|
[populationProbability] | object |
Probabilities of the action to occur based on room population. |
[delay] | number |
Additional delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
[wordLengthMin] | number |
Minimum number of words in a message. Ignored if phrases is set. |
[wordLengthMax] | number |
Maximum number of words in a message. Ignored if phrases is set. |
[phrases] | Array.<string> |
An array of phrases to use as message. Null means random lorem ipsum. |
ActionSleep adds the action to put a character to sleep.
Kind: global class
Creates a new ActionSleep instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ActionSleep parameters.
Kind: inner typedef of ActionSleep
Properties
Name | Type | Description |
---|---|---|
[probability] | number |
Probability of the action to occur. |
[delay] | number |
Delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
ActionTeleport adds the action to teleport.
Kind: global class
Creates a new ActionTeleport instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ActionTeleport parameters.
Kind: inner typedef of ActionTeleport
Properties
Name | Type | Description |
---|---|---|
[populationProbability] | object |
Probabilities of the action to occur based on room population. |
[delay] | number |
Delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
ActionWakeup adds the action to wake up an existing character.
Kind: global class
Creates a new ActionWakeup instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ActionWakeup parameters.
Kind: inner typedef of ActionWakeup
Properties
Name | Type | Description |
---|---|---|
[charLimit] | number |
Limit on how many characters to have awake at any single time. |
[probability] | number |
Probability of the action to occur. |
[delay] | number |
Delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
ActionWhisper adds the action to speak in a room with other characters.
Kind: global class
- ActionWhisper
- new ActionWhisper(app, params)
- instance
- inner
- ~Params :
Object
- ~Params :
Creates a new ActionWhisper instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
Enqueues a whisper action to the botController.
Kind: instance method of ActionWhisper
Param | Type | Description |
---|---|---|
charId | string |
Character ID. |
targetId | string |
Target character ID. |
msg | string |
Message to whisper. |
pose | boolean |
Flag if message is posed. |
priority | number |
Priority of the action. |
ActionWhisper parameters.
Kind: inner typedef of ActionWhisper
Properties
Name | Type | Description |
---|---|---|
[populationProbability] | object |
Probabilities of the action to occur based on room population. |
[delay] | number |
Additional delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
[phrases] | Array.<string> |
An array of phrases to use as message. Null means random lorem ipsum. |
[chars] | Array.<string> |
An array of chars eligible to be whispered to. Null means any. |
BotController is the central module for creating an autonomous, self acting bot. Other modules may register actions that the bot controller may tell the bot-characters to perform.
Kind: global class
- BotController
- new BotController(app, params)
- instance
- inner
- ~Params :
Object
- ~ActionOutcome :
Object
- ~outcomesCallback ⇒
ActionOutcome
|Array.<ActionOutcome>
- ~executeCallback ⇒
string
|Promise.<?string>
- ~Params :
Creates a new BotController instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
Register an action that may be performed by the controller.
Kind: instance method of BotController
Param | Type | Description |
---|---|---|
action | object |
Action definition object. |
action.id | string |
Action ID. |
action.outcomes | outcomesCallback |
Callback that returns an array of possible outcomes. |
action.exec | executeCallback |
Callback that executes one of the action outcomes. |
Unregisters a previously registered action.
Kind: instance method of BotController
Param | Type | Description |
---|---|---|
actionId | string |
Action ID. |
Queues an outcome for an action.
Kind: instance method of BotController
Param | Type | Description |
---|---|---|
action.id | string |
Action ID. |
outcome | ActionOutcome |
Action outcome to queue. |
Validates in a char is under bot control
Kind: instance method of BotController
Param | Type | Description |
---|---|---|
charId | string |
ID of character. |
[opt] | object |
Optional parameters. |
[opt.includeChars] | Array.<string> |
Array of characters to include. If provided, it overrides the includesChars of botController. |
[opt.excludeChars] | Array.<string> |
Array of characters to exclude. If provided, it overrides the excludeChars of botController. |
BotController parameters.
Kind: inner typedef of BotController
Properties
Name | Type | Description |
---|---|---|
[includeChars] | Array.<string> |
Char IDs of chars handled by the bot controller. Null means all characters are included. |
[excludeChars] | Array.<string> |
Char IDs of chars not handled by the bot controller. Null means no character is excluded. |
[queue] | Array |
Initial queue of actions when starting controller. Mainly for debug purpose. |
BotController action outcome. The object may contain any additional properties used by the action to perform the outcome.
Kind: inner typedef of BotController
Properties
Name | Type | Description |
---|---|---|
[probability] | number |
Proportional chance that the outcome will be selected by the bot controller as the next action outsome. |
[delay] | number |
Delay in milliseconds before the action outcome is executed. Defaults to 0. |
[postdelay] | number |
Delay in milliseconds after the action outcome has been executed. Defaults to 0. |
[priority] | number |
Priority of the action outcome when queued. A higher priority outcome will be executed before lower priority outcomes. Defaults to 1. |
BotController~outcomesCallback ⇒ ActionOutcome
| Array.<ActionOutcome>
Outcomes callback This callback is displayed as a global member.
Kind: inner typedef of BotController
Returns: ActionOutcome
| Array.<ActionOutcome>
- Zero or more possible outcomes for the action.
Param | Type | Description |
---|---|---|
player | Model |
Player model. |
state | object |
State object. |
Execute callback called to execute an action outcome.
Kind: inner typedef of BotController
Returns: string
| Promise.<?string>
- Optional string to log, or promise of a string to log. If the promise rejects, it will be logged as an error.
Param | Type | Description |
---|---|---|
player | Model |
Player model. |
state | object |
State object. |
outcome | ActionOutcome |
Outcome to execute. |
Personality holds common personality traits that an action can use to determine behavior.
Kind: global class
- Personality
- new Personality(app, params)
- instance
- .calculateTypeDuration(msg) ⇒
number
- .calculateReadDuration(msg) ⇒
number
- .calculateTypeDuration(msg) ⇒
- inner
- ~Params :
Object
- ~Params :
Creates a new Personality instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
Calculates the time it takes in milliseconds to type a message.
Kind: instance method of Personality
Returns: number
- Duration in milliseconds.
Param | Type | Description |
---|---|---|
msg | string |
Message to type. |
Calculates the time it takes in milliseconds to read a message.
Kind: instance method of Personality
Returns: number
- Duration in milliseconds.
Param | Type | Description |
---|---|---|
msg | string |
Message to read. |
Personality parameters.
Kind: inner typedef of Personality
Properties
Name | Type | Description |
---|---|---|
[typeSpeed] | number |
Type speed in characters per minute. |
[readSpeed] | number |
Read speed in characters per minute. |
ReactionArriveWelcome greets when traveling to a room with other characters.
Kind: global class
Creates a new ReactionArriveWelcome instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ReactionArriveWelcome parameters.
Kind: inner typedef of ReactionArriveWelcome
Properties
Name | Type | Description |
---|---|---|
[populationChance] | object |
Chances of welcoming arrivals, between 0 and 1, based on room population. |
[priority] | number |
Priority of the reply action. |
[delay] | number |
Additional delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
[wordLengthMin] | number |
Minimum number of words in a message. Ignored if phrases is set. |
[wordLengthMax] | number |
Maximum number of words in a message. Ignored if phrases is set. |
[phrases] | Array.<string> |
An array of phrases to use as message. Null means random lorem ipsum. |
ReactionRead intercepts with idle time to read whenever someone else speaks in the room.
Kind: global class
Creates a new ReactionRead instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ReactionRead parameters.
Kind: inner typedef of ReactionRead
Properties
Name | Type | Description |
---|---|---|
[chance] | object |
Chance of reading, between 0 and 1. |
[priority] | number |
Priority of the read action. |
[eventTypes] | Array.<string> |
List of event types to read. Defaults to [ 'say', 'pose', 'ooc', 'describe' ]. |
ReactionTravelGreet greets when traveling to a room with other characters.
Kind: global class
Creates a new ReactionTravelGreet instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ReactionTravelGreet parameters.
Kind: inner typedef of ReactionTravelGreet
Properties
Name | Type | Description |
---|---|---|
[populationChance] | object |
Chances of greeting on entering room, between 0 and 1, based on room population. |
[priority] | number |
Priority of the reply action. |
[delay] | number |
Additional delay in milliseconds to wait prior to executing the action. |
[postdelay] | number |
Delay in milliseconds to wait after executing the action. |
[wordLengthMin] | number |
Minimum number of words in a message. Ignored if phrases is set. |
[wordLengthMax] | number |
Maximum number of words in a message. Ignored if phrases is set. |
[phrases] | Array.<string> |
An array of phrases to use as message. Null means random lorem ipsum. |
ReactionPrivateReply reacts to whispers and enqueues a whisper reply.
Kind: global class
Creates a new ReactionPrivateReply instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
ReactionPrivateReply parameters.
Kind: inner typedef of ReactionPrivateReply
Properties
Name | Type | Description |
---|---|---|
[chance] | object |
Chance of replying, between 0 and 1. |
[priority] | number |
Priority of the action. |
[wordLengthMin] | number |
Minimum number of words in a message. Ignored if phrases is set. |
[wordLengthMax] | number |
Maximum number of words in a message. Ignored if phrases is set. |
[phrases] | Array.<string> |
An array of phrases to use as message. Null means random lorem ipsum. |
CharEvents listens to outgoing log events for any controlled character.
The purpose is to simplify listening and reacting to events for other modules.
Kind: global class
- CharEvents
- new CharEvents(app, params)
- .subscribe(cb) ⇒
function
- .unsubscribe(cb) ⇒
boolean
Creates a new CharEvents instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | CharEvents~Params |
Module parameters. |
Subscribes to char log events.
Kind: instance method of CharEvents
Returns: function
- Unsubscribe function.
Param | Type | Description |
---|---|---|
cb | function |
Callback called on events: function(char, event) |
Unsubscribes to char log events.
Kind: instance method of CharEvents
Returns: boolean
- Returns true if callback was found, eitherwise false.
Param | Type | Description |
---|---|---|
cb | function |
Callback previously passed to the subscribe method. |
CharPing periodically sends a ping for all controlled characters to ensure they are kept awake.
If the botController module is available, it will only ping characters validated by botController.validChar
Kind: global class
- CharPing
- new CharPing(app, params)
- ~Params :
Object
Creates a new CharPing instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
CharPing parameters.
Kind: inner typedef of CharPing
Properties
Name | Type | Description |
---|---|---|
[duration] | number |
Duration in milliseconds between successful pings. |
[threshold] | number |
Threshold in milliseconds after which a character is put to sleep. |
[retry] | number |
Duration in milliseconds beteween retries on failed pings. |
Login logs in the bot after registering it.
Kind: global class
- Login
- new Login(app, params)
- instance
- .getUserPromise() ⇒
Promise.<Model>
- .getUserPromise() ⇒
- inner
- ~Params :
Object
- ~Params :
Creates a new Login instance.
Param | Type | Description |
---|---|---|
app | App |
Modapp App object. |
params | Params |
Module parameters. |
Returns a promise that resolves with the logged in user.
Kind: instance method of Login
Returns: Promise.<Model>
- Promise of the user model.
Login parameters.
Kind: inner typedef of Login
Properties
Name | Type | Description |
---|---|---|
[user] | string |
User account name. |
[pass] | string |
Password, sha256 hashed and base64 encoded, padded with equal (=). Eg. "ZSx9xofZjJiJME7S5AjHS2EehqQMqlHEtD8d1ZE8XNA=" |
Player fetches the player object and keeps it suscribed once logged in.
Kind: global class
- Player
- .getModel() ⇒
Model
- .getPlayerPromise() ⇒
Promise.<Model>
- .getOwnedChar(charId) ⇒
Model
- .getControlledChar(charId) ⇒
Model
- .getModel() ⇒
Returns the module model.
Kind: instance method of Player
Returns: Model
- Module model.
Returns a promise that resolves with the player model, containing all characters and their info, of the logged in user.
Kind: instance method of Player
Returns: Promise.<Model>
- Promise of the player model.
Returns an owned character with a given ID. If the character is not owned, or if the player isn't loaded, null is returned;
Kind: instance method of Player
Returns: Model
- Controlled character model or null.
Param | Type | Description |
---|---|---|
charId | string |
Character ID |
Returns a controlled character with a given ID. If the character is not controlled, or if the player isn't loaded, null is returned;
Kind: instance method of Player
Returns: Model
- Controlled character model or null.
Param | Type | Description |
---|---|---|
charId | string |
Character ID |