<commit_before># Events

Some events will only be fired if you are logged in. If you are not familiar with event listeners, please [read this](https://nodejs.org/api/events.html).

## Contents

- [Action](./Events.html#action)
- [Chat](./Events.html#chat)
- [Clearchat](./Events.html#clearchat)
- [Connected](./Events.html#connected)
- [Connecting](./Events.html#connecting)
- [Disconnected](./Events.html#disconnected)
- [Emotesets](./Events.html#emotesets)
- [Hosted](./Events.html#hosted)
- [Hosting](./Events.html#hosting)
- [Join](./Events.html#join)
- [Logon](./Events.html#logon)
- [Mod](./Events.html#mod)
- [Mods](./Events.html#mods)
- [Notice](./Events.html#notice)
- [Part](./Events.html#part)
- [Ping](./Events.html#ping)
- [Pong](./Events.html#pong)
- [R9kbeta](./Events.html#r9kbeta)
- [Reconnect](./Events.html#reconnect)
- [Roomstate](./Events.html#roomstate)
- [Slowmode](./Events.html#slowmode)
- [Subanniversary](./Events.html#subanniversary)
- [Subscribers](./Events.html#subscribers)
- [Subscription](./Events.html#subscription)
- [Timeout](./Events.html#timeout)
- [Unhost](./Events.html#unhost)
- [Unmod](./Events.html#unmod)
- [Whisper](./Events.html#whisper)

## Action

Received action message on channel. (/me &lt;message&gt;)

**Parameters:**

- ``channel``: _String_ - Channel name
- ``user``: _Object_ - User object
- ``message``: _String_ - Message received
- ``self``: _Boolean_ - Message was sent by the client

~~~ javascript
client.on("action", function (channel, user, message, self) {
    // Do your stuff.
});
~~~

According to Twitch, the user object is always subject to change.

~~~ javascript
{
    color: '#FFFFFF',
    'display-name': 'Schmoopiie',
    emotes: { '25': [ '0-4' ] },
    subscriber: false,
    turbo: true,
    'user-type': 'mod',
    'emotes-raw': '25:0-4',
    username: 'schmoopiie'
}
~~~

## Chat

Received message on channel.

**Parameters:**

- ``channel``: _String_ - Channel name
- ``user``: _Object_ - User object
- ``message``: _String_ - Message received
- ``self``: _Boolean_ - Message was sent by the client

~~~ javascript
client.on("chat", function (channel, user, message, self) {
    // Do your stuff.
});
~~~

According to Twitch, the user object is always subject to change.

~~~ javascript
{
    color: '#FFFFFF',
    'display-name': 'Schmoopiie',
    emotes: { '25': [ '0-4' ] },
    subscriber: false,
    turbo: true,
    'user-type': 'mod',
    'emotes-raw': '25:0-4',
    username: 'schmoopiie'
}
~~~

## Clearchat

Chat of a channel got cleared.

**Parameters:**

- ``channel``: _String_ - Channel name

~~~ javascript
client.on("clearchat", function (channel) {
    // Do your stuff.
});
~~~

## Connected

Connected to server.

**Parameters:**

- ``address``: _String_ - Remote address
- ``port``: _Integer_ - Remote port

~~~ javascript
client.on("connected", function (address, port) {
    // Do your stuff.
});
~~~

## Connecting

Connecting to a server.

**Parameters:**

- ``address``: _String_ - Remote address
- ``port``: _Integer_ - Remote port

~~~ javascript
client.on("connecting", function (address, port) {
    // Do your stuff.
});
~~~

## Disconnected

Got disconnected from server.

**Parameters:**

- ``reason``: _String_ - Reason why you got disconnected

~~~ javascript
client.on("disconnected", function (reason) {
    // Do your stuff.
});
~~~

## Emotesets

Received the ``emote-sets`` from Twitch. The ``emote-sets`` contains your emote set, which you can use to request a subset of ``https://api.twitch.tv/kraken/chat/emoticon_images``

Example: ``https://api.twitch.tv/kraken/chat/emoticon_images?emotesets=0,27,33,793``

**Parameters:**

- ``sets``: _String_ - Your emote sets (always contains at least ``0``)

~~~ javascript
client.on("emotesets", function(sets) {
    // Using our API function..
    client.api({
        url: "/chat/emoticon_images?emotesets=" + sets
    }, function(err, res, body) {
        console.log(body);
    });
});
~~~

## Hosted

Channel is now hosted by another broadcaster. This event is fired only if you are logged in as the broadcaster.

**Parameters:**

- ``channel``: _String_ - Channel name being hosted
- ``username``: _String_ - Username hosting you
- ``viewers``: _Integer_ - Viewers count

~~~ javascript
client.on("hosted", function (channel, username, viewers) {
    // Do your stuff.
});
~~~

## Hosting

Channel is now hosting another channel.

**Parameters:**

- ``channel``: _String_ - Channel name that is now hosting
- ``target``: _String_ - Channel being hosted
- ``viewers``: _Integer_ - Viewers count

~~~ javascript
client.on("hosting", function (channel, target, viewers) {
    // Do your stuff.
});
~~~

## Join

Username has joined a channel. Not available on large channels and is also sent in batch every 30-60secs.

**Parameters:**

- ``channel``: _String_ - Channel name
- ``username``: _String_ - Username

~~~ javascript
client.on("join", function (channel, username) {
    // Do your stuff.
});
~~~

## Logon

Connection established, sending informations to server.

~~~ javascript
client.on("logon", function () {
    // Do your stuff.
});
~~~

## Mod

Someone got modded on a channel.

**Important:** It doesn't detect if ``username`` is a new moderator, it is triggered when jtv gives the moderator status to someone on a channel. You will see a lot of ``mod`` / ``unmod`` events on a channel. When a moderator joins a channel, it will take a few seconds for jtv to give him the moderator status. When leaving a channel, the user gets unmodded.

**Parameters:**

- ``channel``: _String_ - Channel name
- ``username``: _String_ - Username

~~~ javascript
client.on("mod", function (channel, username) {
    // Do your stuff.
});
~~~

## Mods

Received the list of moderators of a channel.

Parameters:

- ``channel``: _String_ - Channel name
- ``mods``: _Array_ - Moderators of the channel

~~~ javascript
client.on("mods", function (channel, mods) {
    // Do your stuff.
});
~~~

## Notice

Received a notice from server. The goal of these notices is to allow the users to change their language settings and still be able to know programmatically what message was sent by the server. We encourage to use the ``msg-id`` to compare these messages.

**Parameters:**

- ``channel``: _String_ - Channel name
- ``msgid``: _String_ - Message ID (See known msg-ids below)
- ``message``: _String_ - Message received

Known msg-ids:

- ``already_banned``: X is already banned in this room.
- ``already_subs_off``: This room is not in subscribers-only mode.
- ``bad_ban_admin``: You cannot ban admin X.
- ``bad_ban_broadcaster``: You cannot ban the broadcaster.
- ``bad_ban_global_mod``: You cannot ban global moderator X.
- ``bad_ban_self``: You cannot ban yourself.
- ``bad_ban_staff``: You cannot ban staff X.
- ``bad_commercial_error``: Failed to start commercial.
- ``bad_mod_banned``: X is banned in this room.
- ``bad_timeout_admin``: You cannot timeout admin X.
- ``bad_timeout_global_mod``: You cannot timeout global moderator X.
- ``bad_timeout_self``: You cannot timeout yourself.
- ``bad_timeout_staff``: You cannot timeout staff X.
- ``bad_unban_no_ban``: X is not banned from this room.
- ``ban_success``: X is now banned from this room.
- ``cmds_available``: Commands available to you in this room (use /help for details)..
- ``color_changed``: Your color has been changed.
- ``commercial_success``: Initiating X second commercial break. Please keep in mind..
- ``msg_banned``: You are permanently banned from talking in channel.
- ``msg_duplicate``: Your message was not sent because you are sending messages too quickly.
- ``msg_subsonly``: This room is in subscribers only mode. To talk, purchase..
- ``msg_timedout``: You are banned from talking in X for Y more seconds.
- ``msg_verified_email``: This room requires a verified email address to chat.
- ``no_help``: No help available.
- ``no_permission``: You don't have permission to perform that action.
- ``timeout_success``: X has been timed out for length seconds.
- ``unban_success``: X is no longer banned from this room.
- ``unrecognized_cmd``: Unrecognized command: X
- ``usage_ban``: Usage: "/ban " - Permanently prevent a user from chatting..
- ``usage_clear``: Usage: "/clear" - Clear chat history for all users in this room.
- ``usage_color``: Usage: "/color <color>" - Change your username color. Color must be..
- ``usage_commercial``: Usage: "/commercial [length]" - Triggers a commercial.
- ``usage_disconnect``: Usage: "/disconnect" - Reconnects to chat.
- ``usage_help``: Usage: "/help" - Lists the commands available to you in this room.
- ``usage_host``: Usage: "/host " - Host another channel. Use "unhost" to unset host mode.
- ``usage_me``: Usage: "/me " - Send an "emote" message in the third person.
- ``usage_mod``: Usage: "/mod " - Grant mod status to a user. Use "mods" to list the..
- ``usage_mods``: Usage: "/mods" - Lists the moderators of this channel.
- ``usage_r9k_on``: Usage: "/r9kbeta" - Enables r9k mode. See http://bit.ly/bGtBDf for details.
- ``usage_r9k_off``: Usage: "/r9kbetaoff" - Disables r9k mode.<commit_msg>docs: updated notice event listener.<commit_after># Events

Some events will only be fired if you are logged in. If you are not familiar with event listeners, please [read this](https://nodejs.org/api/events.html).

## Contents

- [Action](./Events.html#action)
- [Chat](./Events.html#chat)
- [Clearchat](./Events.html#clearchat)
- [Connected](./Events.html#connected)
- [Connecting](./Events.html#connecting)
- [Disconnected](./Events.html#disconnected)
- [Emotesets](./Events.html#emotesets)
- [Hosted](./Events.html#hosted)
- [Hosting](./Events.html#hosting)
- [Join](./Events.html#join)
- [Logon](./Events.html#logon)
- [Mod](./Events.html#mod)
- [Mods](./Events.html#mods)
- [Notice](./Events.html#notice)
- [Part](./Events.html#part)
- [Ping](./Events.html#ping)
- [Pong](./Events.html#pong)
- [R9kbeta](./Events.html#r9kbeta)
- [Reconnect](./Events.html#reconnect)
- [Roomstate](./Events.html#roomstate)
- [Slowmode](./Events.html#slowmode)
- [Subanniversary](./Events.html#subanniversary)
- [Subscribers](./Events.html#subscribers)
- [Subscription](./Events.html#subscription)
- [Timeout](./Events.html#timeout)
- [Unhost](./Events.html#unhost)
- [Unmod](./Events.html#unmod)
- [Whisper](./Events.html#whisper)

## Action

Received action message on channel. (/me &lt;message&gt;)

**Parameters:**

- ``channel``: _String_ - Channel name
- ``user``: _Object_ - User object
- ``message``: _String_ - Message received
- ``self``: _Boolean_ - Message was sent by the client

~~~ javascript
client.on("action", function (channel, user, message, self) {
    // Do your stuff.
});
~~~

According to Twitch, the user object is always subject to change.

~~~ javascript
{
    color: '#FFFFFF',
    'display-name': 'Schmoopiie',
    emotes: { '25': [ '0-4' ] },
    subscriber: false,
    turbo: true,
    'user-type': 'mod',
    'emotes-raw': '25:0-4',
    username: 'schmoopiie'
}
~~~

## Chat

Received message on channel.

**Parameters:**

- ``channel``: _String_ - Channel name
- ``user``: _Object_ - User object
- ``message``: _String_ - Message received
- ``self``: _Boolean_ - Message was sent by the client

~~~ javascript
client.on("chat", function (channel, user, message, self) {
    // Do your stuff.
});
~~~

According to Twitch, the user object is always subject to change.

~~~ javascript
{
    color: '#FFFFFF',
    'display-name': 'Schmoopiie',
    emotes: { '25': [ '0-4' ] },
    subscriber: false,
    turbo: true,
    'user-type': 'mod',
    'emotes-raw': '25:0-4',
    username: 'schmoopiie'
}
~~~

## Clearchat

Chat of a channel got cleared.

**Parameters:**

- ``channel``: _String_ - Channel name

~~~ javascript
client.on("clearchat", function (channel) {
    // Do your stuff.
});
~~~

## Connected

Connected to server.

**Parameters:**

- ``address``: _String_ - Remote address
- ``port``: _Integer_ - Remote port

~~~ javascript
client.on("connected", function (address, port) {
    // Do your stuff.
});
~~~

## Connecting

Connecting to a server.

**Parameters:**

- ``address``: _String_ - Remote address
- ``port``: _Integer_ - Remote port

~~~ javascript
client.on("connecting", function (address, port) {
    // Do your stuff.
});
~~~

## Disconnected

Got disconnected from server.

**Parameters:**

- ``reason``: _String_ - Reason why you got disconnected

~~~ javascript
client.on("disconnected", function (reason) {
    // Do your stuff.
});
~~~

## Emotesets

Received the ``emote-sets`` from Twitch. The ``emote-sets`` contains your emote set, which you can use to request a subset of ``https://api.twitch.tv/kraken/chat/emoticon_images``

Example: ``https://api.twitch.tv/kraken/chat/emoticon_images?emotesets=0,27,33,793``

**Parameters:**

- ``sets``: _String_ - Your emote sets (always contains at least ``0``)

~~~ javascript
client.on("emotesets", function(sets) {
    // Using our API function..
    client.api({
        url: "/chat/emoticon_images?emotesets=" + sets
    }, function(err, res, body) {
        console.log(body);
    });
});
~~~

## Hosted

Channel is now hosted by another broadcaster. This event is fired only if you are logged in as the broadcaster.

**Parameters:**

- ``channel``: _String_ - Channel name being hosted
- ``username``: _String_ - Username hosting you
- ``viewers``: _Integer_ - Viewers count

~~~ javascript
client.on("hosted", function (channel, username, viewers) {
    // Do your stuff.
});
~~~

## Hosting

Channel is now hosting another channel.

**Parameters:**

- ``channel``: _String_ - Channel name that is now hosting
- ``target``: _String_ - Channel being hosted
- ``viewers``: _Integer_ - Viewers count

~~~ javascript
client.on("hosting", function (channel, target, viewers) {
    // Do your stuff.
});
~~~

## Join

Username has joined a channel. Not available on large channels and is also sent in batch every 30-60secs.

**Parameters:**

- ``channel``: _String_ - Channel name
- ``username``: _String_ - Username

~~~ javascript
client.on("join", function (channel, username) {
    // Do your stuff.
});
~~~

## Logon

Connection established, sending informations to server.

~~~ javascript
client.on("logon", function () {
    // Do your stuff.
});
~~~

## Mod

Someone got modded on a channel.

**Important:** It doesn't detect if ``username`` is a new moderator, it is triggered when jtv gives the moderator status to someone on a channel. You will see a lot of ``mod`` / ``unmod`` events on a channel. When a moderator joins a channel, it will take a few seconds for jtv to give him the moderator status. When leaving a channel, the user gets unmodded.

**Parameters:**

- ``channel``: _String_ - Channel name
- ``username``: _String_ - Username

~~~ javascript
client.on("mod", function (channel, username) {
    // Do your stuff.
});
~~~

## Mods

Received the list of moderators of a channel.

Parameters:

- ``channel``: _String_ - Channel name
- ``mods``: _Array_ - Moderators of the channel

~~~ javascript
client.on("mods", function (channel, mods) {
    // Do your stuff.
});
~~~

## Notice

Received a notice from server. The goal of these notices is to allow the users to change their language settings and still be able to know programmatically what message was sent by the server. We encourage to use the ``msg-id`` to compare these messages.

**Parameters:**

- ``channel``: _String_ - Channel name
- ``msgid``: _String_ - Message ID (See known msg-ids below)
- ``message``: _String_ - Message received

Known msg-ids:

- ``already_banned``: X is already banned in this room.
- ``already_subs_off``: This room is not in subscribers-only mode.
- ``bad_ban_admin``: You cannot ban admin X.
- ``bad_ban_broadcaster``: You cannot ban the broadcaster.
- ``bad_ban_global_mod``: You cannot ban global moderator X.
- ``bad_ban_self``: You cannot ban yourself.
- ``bad_ban_staff``: You cannot ban staff X.
- ``bad_commercial_error``: Failed to start commercial.
- ``bad_mod_banned``: X is banned in this room.
- ``bad_timeout_admin``: You cannot timeout admin X.
- ``bad_timeout_global_mod``: You cannot timeout global moderator X.
- ``bad_timeout_self``: You cannot timeout yourself.
- ``bad_timeout_staff``: You cannot timeout staff X.
- ``bad_unban_no_ban``: X is not banned from this room.
- ``ban_success``: X is now banned from this room.
- ``cmds_available``: Commands available to you in this room (use /help for details)..
- ``color_changed``: Your color has been changed.
- ``commercial_success``: Initiating X second commercial break. Please keep in mind..
- ``msg_banned``: You are permanently banned from talking in channel.
- ``msg_duplicate``: Your message was not sent because you are sending messages too quickly.
- ``msg_ratelimit``: Your message was not sent because you are sending messages too quickly.
- ``msg_subsonly``: This room is in subscribers only mode. To talk, purchase..
- ``msg_timedout``: You are banned from talking in X for Y more seconds.
- ``msg_verified_email``: This room requires a verified email address to chat.
- ``no_help``: No help available.
- ``no_permission``: You don't have permission to perform that action.
- ``timeout_success``: X has been timed out for length seconds.
- ``unban_success``: X is no longer banned from this room.
- ``unrecognized_cmd``: Unrecognized command: X
- ``usage_ban``: Usage: "/ban " - Permanently prevent a user from chatting..
- ``usage_clear``: Usage: "/clear" - Clear chat history for all users in this room.
- ``usage_color``: Usage: "/color <color>" - Change your username color. Color must be..
- ``usage_commercial``: Usage: "/commercial [length]" - Triggers a commercial.
- ``usage_disconnect``: Usage: "/disconnect" - Reconnects to chat.
- ``usage_help``: Usage: "/help" - Lists the commands available to you in this room.
- ``usage_host``: Usage: "/host " - Host another channel. Use "unhost" to unset host mode.
- ``usage_me``: Usage: "/me " - Send an "emote" message in the third person.
- ``usage_mod``: Usage: "/mod " - Grant mod status to a user. Use "mods" to list the..
- ``usage_mods``: Usage: "/mods" - Lists the moderators of this channel.
- ``usage_r9k_on``: Usage: "/r9kbeta" - Enables r9k mode. See http://bit.ly/bGtBDf for details.
- ``usage_r9k_off``: Usage: "/r9kbetaoff" - Disables r9k mode.
{'fraction_non_alphanumeric': 0.16102065348049394, 'fraction_numerical': 0.0040432739591301494, 'mean_word_length': 3.941414686825054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '711296', 'n_tokens_mistral': 6054, 'n_tokens_neox': 5809, 'n_words': 1954}