Constructor
new TwitchChat(optionsopt)
This module connects to the twitch irc and parses messages
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Optional connections options |
- TwitchChat#event:connect
- TwitchChat#event:error
- TwitchChat#event:close
- TwitchChat#event:incoming
- TwitchChat#event:raw
- TwitchChat#event:registered
- TwitchChat#event:motd
- TwitchChat#event:hostingyou
- TwitchChat#event:autohostingyou
- TwitchChat#event:action
- TwitchChat#event:message
- TwitchChat#event:whisper
- TwitchChat#event:capack
- TwitchChat#event:names
- TwitchChat#event:join
- TwitchChat#event:part
- TwitchChat#event:mode+
- TwitchChat#event:mode-
- TwitchChat#event:mode
- TwitchChat#event:notice
- TwitchChat#event:usernotice
- TwitchChat#event:clearuser
- TwitchChat#event:clearchat
- TwitchChat#event:userstate
- TwitchChat#event:roomstate
- TwitchChat#event:outgoing
Extends
- EventEmitter
Members
Object
options
Connection options
Properties:
Name | Type | Description |
---|---|---|
host |
String | |
port |
Number | |
auto_reconnect |
Boolean |
Methods
join(channel)
Join a channel
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel that should be joined |
part(channel, cb)
Leave a channel
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel that should be left |
cb |
function | A callback that is called when the channel was left |
say(dest, msg)
Send a message to a channel
Parameters:
Name | Type | Description |
---|---|---|
dest |
String | The channel that the channel is sent to |
msg |
String | The message that is being sent |
sendCLRF(message)
Send a raw command to the server
Parameters:
Name | Type | Description |
---|---|---|
message |
String | The command or message that is being sent |
Events
action
Fires when a user sends an action message. It's exactly like a normal message but is usually display in the user name color.
Parameters:
Name | Type | Description |
---|---|---|
prefix |
Object | Message prefix - there is usually nothing interesting here |
user |
String | Username in the prefix |
host |
String | Host in the prefix |
user |
String | Username that sent the message |
channel |
String | Channel that the message was sent to |
message |
String | The message that was sent |
tags |
Object | The message tags |
autohostingyou
Fires when someone is auto hosting the channel. Only the channel owner will receive these.
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | Channel that the message was sent to |
user |
String | The user that hosts you |
viewers |
Number | How many viewers are being hosted |
message |
String | The system message |
tags |
Object | Tag object |
clearchat
Fires when the entire chat is being cleared
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel that is being cleared |
tags |
Object | The message tags |
clearmsg
Fires when messages of a specific message was deleted.
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the messages were deleted in |
user |
String | The user the messages were deleted from |
msgId |
String | The message UUID that is being deleted |
clearuser
Fires when messages of a specific user was deleted.
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the messages were deleted in |
user |
String | The user the messages were deleted from |
tags |
String | The message tags |
close
Fired when connection is closing
Parameters:
Name | Type | Description |
---|---|---|
had_error |
Boolean | Did the socket close because of an error? |
connect
Is fired when connection is established
Parameters:
Type | Description |
---|---|
net.Socket |
error
Is fired on any connection error
Parameters:
Type | Description |
---|---|
Error |
hostingyou
Fires when someone is hosting the channel. Only the channel owner will receive these.
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | Channel that the message was sent to |
user |
String | The user that hosts you |
viewers |
Number | How many viewers are being hosted |
message |
String | The system message |
tags |
Object | Tag object |
incoming
Is fired on any CRLF that is send
Parameters:
Name | Type | Description |
---|---|---|
message |
String | Undoctored message as it came in (without the CRLF) |
join
Fires when someone joins a channel the user is in
Parameters:
Name | Type | Description |
---|---|---|
user |
String | The user that joined |
channel |
String | The channel the user joined to |
message
Fires when a user sends an message
Parameters:
Name | Type | Description |
---|---|---|
prefix |
Object | Message prefix - there is usually nothing interesting here |
user |
String | Username in the prefix |
host |
String | Host in the prefix |
user |
String | Username that sent the message |
channel |
String | Channel that the message was sent to |
message |
String | The message that was sent |
tags |
Object | The message tags |
mode
Fires on every mode change
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the mode was changed in |
mode |
String | The mode that was changed |
user |
String | The user that the mode was change of |
mode+
Fires when a user's mode was added
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the mode was changed in |
mode |
String | The mode that was added |
user |
String | The user that received the mode |
mode-
Fires when a user's mode was removed
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the mode was changed in |
mode |
String | The mode that was removed |
user |
String | The user that the mode was revoked from |
motd
Fired when the message of the day was sent, usually directly after the welcom message
Parameters:
Name | Type | Description |
---|---|---|
motd |
String | Message of the day |
names
Fires when a channel name list were being sent
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the list is for |
namelist |
Array.<String> | An array of names of users in the channel |
notice
Fires when the server sends a notice. These are general system messages.
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the notice was sent in |
message |
String | The message that was sent |
tags |
String | Tags of the message |
outgoing
Fires when a message is being sent to server
Parameters:
Name | Type | Description |
---|---|---|
message |
String | The raw message that is being sent to the server (without CRLF) |
part
Fires when someone leaves a channel the user is in.
Parameters:
Name | Type | Description |
---|---|---|
user |
The user that left the channel | |
channel |
The channel the user left from |
raw
A more splitted message than TwitchChat#incoming
Parameters:
Name | Type | Description |
---|---|---|
tags |
String | String of the tags |
prefix |
Object | String of the prefix |
user |
String | Username in the prefix |
host |
String | Host in the prefix |
action |
String | IRC action code |
attach |
String | Everything after the IRC action |
reconnect
Is fired when connection being retried automatically in n seconds
Parameters:
Name | Type | Description |
---|---|---|
timeout |
number | Timeout before reconnection is tried |
roomstate
Fires when the server sends a roomstate. Usually when a user joins a channel to get the current sate the channel is in.
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the tags are meant for |
tags |
Object | The channel tags |
usernotice
Fires when the server sends a usernotice. This is used for sending subscriptions.
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the usernotice was sent to |
tags |
Object | The message tags |
message |
String | The message the user added to the sub share. Might be empty if no message was added. |
userstate
Fires when the server sends a userstate. This is send on every message the user sends and when he joins a channel.
Parameters:
Name | Type | Description |
---|---|---|
channel |
String | The channel the tags are meant for |
tags |
Object | The user tags for the logged in user |
whisper
Fires if a user whispers to the logged in user.
Parameters:
Name | Type | Description |
---|---|---|
prefix |
Object | Message prefix - there is usually nothing interesting here |
user |
String | Username in the prefix |
host |
String | Host in the prefix |
user |
String | Username that sent the message |
message |
String | Message the user sent |
tags |
Object | The message tags |