In order to connect to Twitch IRC, you must have two pieces of information:
- The name of channel that you want to join.
- A Twitch account.
- Oauth token from API or from a site using it: www.twitchapps.com/tmi
Once you have that information, you can then take it to connect to Twitch IRC with the following bits of information:
- The server name to connect to is: irc.twitch.tv.
- The port to connect to is 6667
- SSL is not supported for Twitch IRC.
- Your nickname must be your Twitch nickname
- Your password should be an OAuth token. You can get your oauth token here: www.twitchapps.com/tmi (Thanks Andrew Bashore!)
- An example "password" using this method would be "oauth:asdasd234asd234ad234asds23" without quotes.
- This is a "server password" in programs like hexchat.
- mIRC may require you to enter the password into the GUI.
Upon a Successful ConnectionNote: Lines prefixed with < are sent from client to server, and lines prefixed with > are sent from the server to the connecting client.
A successful connection session will look something like this:
< PASS oauth:twitch_oauth_token < NICK twitch_username > :tmi.twitch.tv 001 twitch_username :connected to TMI > :tmi.twitch.tv 002 twitch_username :your host is TMI > :tmi.twitch.tv 003 twitch_username :this server is pretty new > :tmi.twitch.tv 004 twitch_username tmi.twitch.tv 0.0.1 w n > :tmi.twitch.tv 375 twitch_username :- tmi.twitch.tv Message of the day - > :tmi.twitch.tv 372 twitch_username :- not much to say here > :tmi.twitch.tv 376 twitch_username :End of /MOTD command
On an Unsuccessful Connection
If your connection fails for any reason, you will be disconnected from the server. Some common reasons for being disconnected immediately include:
- Connecting on the wrong port
- Connecting to the wrong server
- Using an incorrect username and/or password
Command & Message Limit
- If you send more than 20 commands or messages to the server within a 30 second period, you will get locked out for 8 hours automatically. These are not lifted so please be careful when working with IRC!
Commands you can sendMost normal chat commands like /timeout, /ban, /clear are sent with periods in place of the forward slash. For example, to ban the user xangold, you would send .ban xangold to the server.
Note: Lines prefixed with < are sent from client to server, and lines prefixed with > are sent from the server to the connecting client.
If you send an invalid command, you will receive a 421 numeric back:
< CAP REQ :multi-prefix > :tmi.twitch.tv 421 you CAP :Unknown command
A brief list of commands supported by our IRC server include:
JOIN: Opening up a chat room (and obtaining a list of users)
After a successful JOIN, the following will take place:
- You will be sent a list of users that are currently in the channel.
- A number of MODEs will be set from the jtv user to signify that a user can moderate chat. Users that can moderate chat are are defined as Channel Moderators, Admin's and Staff.
< JOIN #channelname > JOIN #channelname > 353: = #channelname nickname nickname2 nickname3 nickname4 anotherNickname > 353: = #channelname nickname25 nickname26 nicknameN > 366: #channelname End of /NAMES list > jtv MODE #channelname +o channel_moderator > jtv MODE #channelname +o channel_moderator2 > jtv MODE #channelname +o staff_user > jtv MODE #channelname +o twitch_global_mod_user
PART: Leaving a chat room
< PART #channelname > PART #channelname
WHO: Obtaining a detailed list of users
< WHO #channelname > 352: #channelname nickname channelname.tmi.twitch.tv tmi.twitch.tv username H 0 realname > 352: #channelname nickname2 channelname.tmi.twitch.tv tmi.twitch.tv username H 0 realname > ... > 352: #channelname nicknameN channel.tmi.twitch.tv tmi.twitch.tv username H 0 realname > 315: #channelname End of /WHO list
Commands you may receive
JOIN: Someone joined a channel!
:email@example.com JOIN #channelname
PART: Someone parted a channel
:firstname.lastname@example.org PART #channelname
PRIVMSG: Someone sent a message to a channel
:email@example.com PRIVMSG #channel :message that was sent
Further notes about lists of users
- A list of users that are currently in a channel is sent after a successful JOIN, so WHO is often not required.
- Due to caching, JOINs and PARTs are not sent immediately to a channel. They are instead batched up and sent every 10 seconds.
- After receiving your initial list of users or after performing your first WHO, it is recommended to process PARTs and JOINs as they come in instead of re-requesting this list from the server.
- Due to caching, the response of this command may be delayed by up to 10 seconds on initial connect and may be up, but no more than, to 10 seconds out of date.
- You cannot request a list of users for a channel that you did not JOIN.