User:Dessamator/Chat extension docs

This documents some of the api calls that can be used in an Wikia's chat extension.

Basics
Scripts for the chat extension must be stored or loaded from MediaWiki:Chat.js. If using a script that manipulates data sent to other users keep in mind the fact that these are sent asynchronously.

Internal API
The chat extension exposes variables that can be overwritten to allow access to internal events. The main one is. These are not generally meant for public use, and the chat extension doesn't seem to have a public API.

Events
There are a couple of "common" events s that can be manipulated.

New user joining
This can be accessed through the mainRoom variable by the use of a socket.bind function. Note that $.proxy is a jquery function. The "join" event is executed whenever a new user logs into the chat.

User logout
In this instance the "logout" event is executed whenever a user disconnects from chat. Note that this may either be intentional, e.g. close window, or unintentional, bad connection or being banned from chat.

After add event
This event seems to be executed whenever any text is added to the chat. This is useful for checking if a string is present, or for triggering notifications.

Sending a message
It is possible to send a message using a client by emulating a normal send operation. There are of course other ways of doing so like hacking the internal API. But for the most part this is unnecessary.