The protocol operates on a websocket in text mode. Messages sent between the client and server are a series of concatenated strings delimited by the vertical tab character, represented in most languages by the escape sequence `\t` and defined in ASCII as `0x09`.
The first string in this concatenation must be the packet identifier, sent as an `int`.
Newer versions of the protocol are implemented as extensions, a client for Version 1 should have no trouble using a server built for Version 2 as long as authentication is understood.
The current stable version of the protocol is **Version 1**.
A value that indicates a true or a false state. `0` represents false and anything non-`0` represents true, please stick to `1` for representing true though.
User permissions are a set of flags separated by either the form feed character (`\f` / `0x0C`) or a space (<code></code> / `0x20`).
The reason there are two options is due to a past mixup that we now have to live with.
Which of the methods is used remains consistent per server however, so the result of a test can be cached.
<table>
<tr>
<td><code>int</code></td>
<td>Rank of the user. Used to determine what channels a user can access or what other users the user can moderate.</td>
<td></td>
</tr>
<tr>
<td><code>bool</code></td>
<td>Indicates whether the user the ability kick/ban/unban others.</td>
<td></td>
</tr>
<tr>
<td><code>bool</code></td>
<td>Indicates whether the user can access the logs. This should always be <code>0</code>, unless the client has a dedicated log view that can be accessed without connecting to the chat server.</td>
<td></td>
</tr>
<tr>
<td><code>bool</code></td>
<td>Indicates whether the user can set an alternate display name.</td>
<td></td>
</tr>
<tr>
<td><code>int</code></td>
<td>Indicates whether the user can create channel. If <code>0</code> the user cannot create channels, if <code>1</code> the user can create channels but they are to disappear when all users have left it and if <code>2</code> the user can create channels that permanently stay in the channel assortment.</td>
While authenticated this packet indicates that a new user has joined the server/channel. Before authentication this packet serves as a response to client packet `1`: Authentication.
#### Successful authentication response
Informs the client that authentication has succeeded.
<table>
<tr>
<td><code>string</code></td>
<td><code>y</code></td>
<td></td>
</tr>
<tr>
<td><code>int</code></td>
<td>User ID</td>
<td></td>
</tr>
<tr>
<td><code>string</code></td>
<td>Username</td>
<td></td>
</tr>
<tr>
<td><code>color</code></td>
<td>Username color</td>
<td></td>
</tr>
<tr>
<td><code>user permissions</code></td>
<td>User permissions</td>
<td></td>
</tr>
<tr>
<td><code>channel name</code></td>
<td>Default channel the user will join following this packet</td>
Informs the client that a chat message has been received.
<table>
<tr>
<td><code>timestamp</code></td>
<td>Time when the message was received by the server</td>
<td></td>
</tr>
<tr>
<td><code>int</code></td>
<td>
User ID.
If <code>-1</code> this message is an informational message from the server and the next field takes on a special form.
</td>
<td></td>
</tr>
<tr>
<td><code>string</code></td>
<td>
<p>Message, sanitised by the server</p>
<p>
If this is an informational message this field is formatted as follows and concatenated by the form feed character <code>\f</code>, respresented in ASCII by <code>0x0C</code>. Bot message formats are described lower in the document.
<table>
<tr>
<td><code>int</code></td>
<td>
Message type.
<ul>
<li><code>0</code> for a normal informational message.</li>
<li><code>1</code> for an error.</li>
</ul>
</td>
</tr>
<tr>
<td><code>string</code></td>
<td>An id of a string in the legacy language files.</td>
</tr>
<tr>
<td><code>...string</code></td>
<td>Any number of parameters used to format the language string.</td>
Informs the client that their silence has been revoked.
#### `silok`: Silence confirmation
Informs the client that they have successfully silenced another user.
##### Arguments
-`string`: Username of the user.
#### `usilok`: Silence revocation confirmation
Informs the client that they have successfully revoked another user's silence.
##### Arguments
-`string`: Username of the user.
#### `flwarn`: Flood protection warning
Informs the client that they are risking getting kicked for flood protection (spam) if they continue sending messages at the same rate.
#### `unban`: Ban revocation confirmation
Informs the client that they have successfully revoked a ban on a user or an IP address.
#### `banlist`: List of banned entities
Provides the client with a list of all banned users and IP addresses.
##### Arguments
-`string`: HTML with the information on the users with the following format: "<code><a href="javascript:void(0);" onclick="Chat.SendMessageWrapper('/unban '+ this.innerHTML);">{0}</a></code>" where {0} is the username of the banned user or the banned IP address. The set is separated by "<code>, </code>".
#### `who`: List of online users
Provides the client with a list of users currently online on the server.
##### Arguments
-`string`: HTML with the information on the users with the following format: "<code><a href="javascript:void(0);" onclick="UI.InsertChatText(this.innerHTML);">{0}</a></code>" where {0} is the username of a user. The current online user is highlighted with "<code> style="font-weight: bold;"</code>" before the closing > of the opening <a> tag. The set is separated by "<code>, </code>".
#### `whochan`: List of users in a channel.
Provides the client with a list of users currently online in a channel.
##### Arguments
-`string`: HTML with the information on the users with the following format: "<code><a href="javascript:void(0);" onclick="UI.InsertChatText(this.innerHTML);">{0}</a></code>" where {0} is the username of a user. The current online user is highlighted with "<code> style="font-weight: bold;"</code>" before the closing > of the opening <a> tag. The set is separated by "<code>, </code>"
#### `join`: User connected
Informs the client that a user just connected to the server.
##### Arguments
-`string`: Username of the user.
#### `jchan`: User joined channel
Informs the client that a user just joined a channel they're in.
##### Arguments
-`string`: Username of the user.
#### `leave`: User disconnected
Informs the client that a user just disconnected from the server.
##### Arguments
-`string`: Username of the user.
#### `lchan`: User left channel
Informs the client that a user just left a channel they're in.
#### `kick`: User has been kicked
Informs the client that another user has just been kicked.
##### Arguments
-`string`: Username of the user.
#### `flood`: User exceeded flood limit
Informs the client that another user has just been kicked for exceeding the flood protection limit.
##### Arguments
-`string`: Username of the user.
#### `timeout`: User has timed out
Informs the client that another user has been disconnected from the server automatically.
##### Arguments
-`string`: Username of the user.
#### `nick`: User has changed their nickname
Informs the client that a user has changed their nickname.
##### Arguments
-`string`: Previous username of the user.
-`string`: New username of the user.
#### `crchan`: Channel creation confirmation
Informs the client that the channel they attempted to create has been successfully created.
##### Arguments
-`string`: Name of the target channel.
#### `delchan`: Channel deletion confirmation
Informs the client that the channel they attempted to delete has been successfully deleted.
Informs the client that they are not allowed to revoke the silence on the other user.
#### `silself`: Self silence
Informs the client that they are not allowed to silence themselves.
## Commands
Actions sent through messages prefixed with `/`. Arguments are described as `[name]`, optional arguments as `[name?]`. The `.` character is ignored in command names (replaced by nothing).
### `/afk`: Setting status to away
Marks the current user as afk, the first 5 characters from the user string are prefixed uppercase to the current username prefixed by `&lt;` and suffixed by `&gt;_` resulting in a username that looks like `<AWAY>_flash` if `/afk away` is ran by the user `flash`. If no reason is specified "`AFK`" is used.
#### Format
```
/afk [reason?]
```
### `/nick`: Change nickname
Temporarily changes the user's nickname, generally with a prefix such as `~` to avoid name clashing with real users. If the user's original name or no argument at all is specified, the command returns the user's name to its original state without the prefix.
#### Format
```
/nick [name?]
```
#### Responses
-`cmdna`: User is not allowed to change their own nickname.
-`nameinuse`: The specified nickname is already in use by another user.
-`usernf`: Target user could not be found by the server.
### `/me`: Describing an action
Sends a message but with flags `11000` instead of the regular `10010`, used to describe an action.
#### Format
```
/me [message]
```
#### Aliases
-`/action`
### `/who`: Requesting a user list
Requests a list of users either currently online on the server in general or in a channel. If no argument is specified it'll return all users on the server, if a channel is specified it'll return all users in that channel.
#### Format
```
/who [channel?]
```
#### Responses
-`nochan`: The given channel does not exist.
-`whoerr`: The user does not have access to the channel.
-`whochan`: Listing of users in the channel.
-`who`: Listing of users in the server.
### `/delete`: Deleting a message or channel
Due to an oversight in the original implementation, this command was specified to be both the command for deleting messages and for channels. Fortunately messages always have numeric IDs and channels must start with an alphabetic character. Thus if the argument is entirely numeric this function acts as an alias for `/delmsg`, otherwise `/delchan`.
#### Format
```
/delete [channel name or message id]
```
#### Responses
Inherits the responses of whichever command is forwarded to.
### `/join`: Joining a channel
Switches or joins the current user to a different channel.
#### Format
```
/join [channel] [password?]
```
#### Responses
-`nochan`: The given channel does not exist.
-`ipchan`: The client does not have the required rank to enter the given channel.
-`nopwchan`: A password is required to enter the given channel.
-`ipwchan`: The password provided was invalid.
### `/leave`: Leaving a channel
Leave a specified channel.
#### Format
```
/leave [channel]
```
#### Responses
-`nocmd`: The client tried to run this command without specifying the `MCHAN` capability.
### `/create`: Creating a channel
Creates a new channel.
#### Format
```
/create [rank?] [name...]
```
If the first argument is numeric, it is taken as the minimum required rank to join the channel. All further arguments are glued with underscores to create the channel name.
#### Responses
-`cmdna`: The client is not allowed to create channels.
-`cmderr`: The command is formatted incorrectly.
-`rankerr`: The specified rank is higher than the client's own rank.
-`inchan`: The given channel name contains invalid characters.
-`nischan`: A channel with this name already exists.
-`crchan`: The channel has been created successfully.
### `/delchan`: Deleting a channel
Deletes an existing channel.
#### Format
```
/delchan [name]
```
#### Responses
-`cmderr`: The command is formatted incorrectly.
-`nochan`: No channel exists with this name.
-`ndchan`: The client is not allowed to delete this channel.
-`delchan`: The target channel has been deleted.
### `/password`: Update channel password
Changes the password for a channel. Removes the password if no argument is given.
#### Format
```
/password [password?]
```
#### Aliases
-`/pwd`
#### Responses
-`cmdna`: The client is not allowed to change the password for this channel.
-`cpwdchan`: The password of the channel has been successfully updated.
### `/rank`: Update channel minimum rank
Changes what user rank is required to enter a channel.
#### Format
```
/rank [rank]
```
#### Aliases
-`/privilege`
-`/priv`
#### Responses
-`cmdna`: The client is not allowed to change the rank of the target channel.
-`rankerr`: Missing rank argument or the given rank is higher than the client's own rank.
-`cprivchan`: The minimum rank of the channel has been successfully updated.
### `/say`: Broadcast a message
Broadcasts a message as the server/chatbot to all users in all channels.
#### Format
```
/say [message]
```
#### Responses
-`cmdna`: The client is not allowed to broadcast messages.
-`say`: The broadcasted message.
### `/delmsg`: Deleting a message
Deletes a given message.
#### Format
```
/delmsg [message id]
```
#### Responses
-`cmdna`: The client is not allowed to delete messages.
-`cmderr`: The given message ID was invalid.
-`delerr`: The target message does not exist or the client is not allowed to delete this message.
### `/kick`: Kick a user
Kicks a user from the serer. If not time is specified, then kick expires immediately.
#### Format
```
/kick [username] [time?]
```
#### Responses
-`cmdna`: The client is not allowed to kick others.
-`usernf`: The target user could not be found on the server.
-`kickna`: The client is trying to kick someone who they are not allowed to kick, or someone that is currently banned.
-`cmderr`: The provided time is invalid.
### `/ban`: Bans a user
Bans a user and their IP addresses from the server. If no time is specified the ban will never expire.
#### Format
```
/ban [user] [time?]
```
#### Responses
-`cmdna`: The client is not allowed to kick others.
-`usernf`: The target user could not be found on the server.
-`kickna`: The client is trying to kick someone who they are not allowed to kick, or someone that is currently banned.
-`cmderr`: The provided time is invalid.
### `/pardon`: Revokes a user ban
Revokes a ban currently placed on a user.
#### Format
```
/pardon [user]
```
### Aliases
-`/unban`
#### Responses
-`cmdna`: The client is not allowed to revoke user bans.
-`notban`: The target user is not banned.
-`unban`: The ban on the target user has been successfully revoked.
### `/pardonip`: Revokes an IP address ban
Revokes a ban currently placed on an IP address.
#### Format
```
/pardonip [address]
```
#### Aliases
-`/unbanip`
#### Responses
-`cmdna`: The client is not allowed to revoke IP bans.
-`notban`: The target address is not banned.
-`unban`: The ban on the target address has been successfully revoked.
### `/bans`: List of bans
Retrieves a list of banned users and IP addresses.
#### Format
```
/bans
```
#### Aliases
-`/banned`
#### Responses
-`cmdna`: Not allowed to view banned users and IP addresses.
-`banlist`: The list of banned users and IP addresses.
### `/silence`: Silence a user
Silences a user. If the time argument is not specified, the silence is indefinite.
#### Format
```
/silence [username] [time?]
```
#### Responses
-`cmdna`: The client is not allowed to silence users.
-`usernf`: The target user could not be found on the server.
-`silself`: The client tried to silence themselves.
-`silperr`: The target user has a higher rank that the client.
-`silerr`: The target user is already silenced.
-`cmderr`: The time argument is formatted incorrectly.
-`silence`: Informs the target user that they have been silenced.
-`silok`: The target has been successfully silenced.
### `/unsilence`: Revokes a user silence
Revokes a user's silenced status.
#### Format
```
/unsilence [username]
```
#### Responses
-`cmdna`: The client is not allowed to revoke silences.
-`usernf`: The target user could not be found.
-`usilperr`: The target user has a higher rank than the client.
-`usilerr`: The target user isn't silenced.
-`unsil`: Informs the target user that their silenced status has been revoked.
-`usilok`: The silenced status placed on the target has been successfully revoked.
### `/ip`: Retrieve IP addresses
Retrieves a user's IP addresses. If the user has multiple connections, multiple `ipaddr` responses may be sent.
#### Format
```
/ip [username]
```
#### Aliases
-`whois`
#### Responses
-`cmdna`: The client is not allowed to view IP addresses.
-`usernf`: The target user is not connected to the server.
-`ipaddr`: (One of) The target user's IP address(es).