ChatRoomMessageHandler
Index
Properties
Properties
Callback
Actual action to perform.
Type declaration
Parameters
data: ServerChatRoomMessage
The chat message to handle.
sender: Character
The character that sent the message.
msg: string
The formatted string extracted from the message. If the handler is in "post" mode, all substitutions have been performed.
optionalmetadata: IChatRoomMessageMetadata
The collected metadata from the message's dictionary, only available in "post" mode.
Returns boolean | { msg?: string; skip?: (handler: ChatRoomMessageHandler) => boolean }
optionalDescription
A short description of what the handler does. For debugging purposes
Priority
This handler's priority, used to determine when the code should run.
A chat message handler.
This is used in ChatRoomMessage to perform filtering and actions on the recieved message. You can register one of those with ChatRoomRegisterMessageHandler if you need to peek at incoming messages.
Message processing is done in three phases:
The handler's priority determines when the handler will get executed:
The return from the callback determines what will happen: if it's true, message processing will stop, making the filter act like a handler. If it's false, then it will continue. You can also return an object with a
msg
property if the handler is a transformation and wishes to update the message's contents inflight and/or askip
property if you'd like to cause a subsequent handler to not be called.Note that the in-flight message is only escaped when it gets sent to the chat log via ChatRoomMessageDisplay. If you're manipulating that by any other means, make sure to call ChatRoomEscapeEntities on its content to close any injection attacks.
A few notable priority values are:
-200: ghosted player cutoff -1: default Hidden message processing (and cutoff) 0: emotes reformatting 100: sensory-deprivation processing 200: automatic actions on others' cutoff 300: sensory-deprivation cutoff. 500: usually output handlers. That's when audio, notifications and the message being added to the chat happens.
Hidden messages never make it to post-processing.