Railgun

if it ain't broke, we'll break it

User Tools

Site Tools


senses:globals:satori

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

  1. The first argument should contain a handler callback function, the syntax of which is described below.
  2. 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

  1. The first argument will contain a message type table.
  2. The second argument will contain a boolean indicating whether the message was one sent by the bot itself.

Returns

  1. 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 the img command. A boolean value of false 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