Prior to most of the chat system processing of the event, the registered callbacks are executed in the order they were added. If any callback alters the event
object in argument 0, then that change will be propagated to any subsequent callbacks and used when the chat system updates the DOM after all registered callbacks have been executed. If any callback returns a truthy value, then no further callbacks are executed and the chat system doesn't do any of its normal processing of the event (i.e. the DOM will not be updated). Effectively, returning a truthy value from a callback cancels the event.
The first argument is a chat "event" Object. This answer on MSE has a list and description of the possible key/value pairs, at least for event_type == 1
. The most common key/value pairs which may be included for messages which are not shown above are show_parent
and parent_id
. The show_parent
key is only present if the message is an actual reply to the message ID indicated in parent_id
. parent_id
will be present for actual replies and @
pings. For @
pings, parent_id
will be the most recent message by the pinged user and show_parent
won't be present.
The type of event is indicated by the numeric value of event_type
. There are 34 types which are possible for event_type
.