====== satori ====== The satori global contains the context relevant to the state of the bot user designated as Satori. It extends the [[senses:types:bot-context|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 [[https://patchii.net/flashii/komeiji-senses/src/commit/c97e0a151d71c9fc4242c30975598257269ce7ff/booru/booru.lua#L168|booru]] Sense, or to process messages in an arbitrary, non-command invoked manner, such as done by the [[https://patchii.net/flashii/komeiji-senses/src/commit/c97e0a151d71c9fc4242c30975598257269ce7ff/deepl/cmd.lua#L9|urlmeta]] and [[https://patchii.net/flashii/komeiji-senses/src/commit/c97e0a151d71c9fc4242c30975598257269ce7ff/urlmeta/hook.lua#L8|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 [[senses:types:message|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 [[https://patchii.net/flashii/komeiji-senses/src/commit/c97e0a151d71c9fc4242c30975598257269ce7ff/booru/booru.lua#L168|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.