twitch Twitch Chat (IRC) Bot

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

Twitch Chat is a simple IRC chat. For any serious development, there are multiple documents for it, including the most comprehensive and general ressource: http://ircdocs.horse/

Connection, Handshake

IRC is a basic, plaintext based TCP protocol. Connecting to Twitch works just like any regular IRC service with a difference in authenticating:

Connection Initiation > Handshake > Usage

The handshake is regularly the hardest part to get right:

After building up the connection to the server, you are required to provide PASS and then a NICK, where PASS is an OAuth-Token (which you can generate here) and USER being the username to this OAuth token.

The handshake is then as following (< being sent from client to server, > being sent from server to client):

< PASS oauth:your_oauth_token
< NICK your_username
> :tmi.twitch.tv 001 your_username :connected to TMI
> :tmi.twitch.tv 002 your_username :your host is TMI
> :tmi.twitch.tv 003 your_username :this server is pretty new
> :tmi.twitch.tv 004 your_username tmi.twitch.tv 0.0.1 w n
> :tmi.twitch.tv 375 your_username :- tmi.twitch.tv Message of the day - 
> :tmi.twitch.tv 372 your_username :- not much to say here
> :tmi.twitch.tv 376 your_username :End of /MOTD command

Once you received either any of these MODE, 376 or 422, you're good to go and can send the twitch server any commands, like:

> JOIN :#gamesdonequick
> PRIVMSG #gamesdonequick :Hello world!

A more throughout guide to client-server commands can be found here.

Twitch-specific Capabilities

While Twitch uses a standard IRC service, there are some events seen on the IRC service which correlate to activity in a channel on the Twitch website. Examples here are slowmode being enabled or disabled, subscriber-only mode being enabled/disabled on a streamer's chat, hosting activity, and bits/cheer activity, among others.

Details on these Twitch-specific capabilities are listed in the GitHub documentation for Twitch IRC, which can be found here.



Got any twitch Question?