senses:globals:satori
Table of Contents
satori
The satori global contains the context relevant to the state of the bot user designated as Satori. It extends the bot context type.
addMessageHandler
The additional addMessageHandler field contains a function for adding handlers to the message processing of Satori. This can be used to alter the body text of a message, such as done by the booru Sense, or to process messages in an arbitrary, non-command invoked manner, such as done by the urlmeta and deepl Senses.
Syntax
addMessageHandler(handler: function, afterCommand: boolean = false): ()
Arguments
- The first argument should contain a handler callback function, the syntax of which is described below.
- The second argument may contain a boolean value to indicate at which stage of the pipeline the handler should be inserted. If
true
and a command was successfully invoked, the handler will not be executed.
Returns
This function has no return values.
Message handler
Message handlers are a type of callback that can be used to intercept the message processing pipeline.
Syntax
handler(message: table, isSelf: boolean): (result: string|boolean|nil)
Arguments
- The first argument will contain a message type table.
- The second argument will contain a boolean indicating whether the message was one sent by the bot itself.
Returns
- The first return value may contain either a boolean or a string. A string value will replace the message body with that value for the remaining message handlers, including the command handler if this handler was inserted before it, this is done by the booru Sense to provide the
~
alias for theimg
command. A boolean value offalse
will abort the handler pipeline,true
behaves the same way as if no return value was given. Any other return value type is ignored.
senses/globals/satori.txt · Last modified: by flash