Skip to content

Instantly share code, notes, and snippets.

@hunterbridges
Last active December 8, 2024 02:15
Show Gist options
  • Save hunterbridges/ab095066d40f2e1a243e to your computer and use it in GitHub Desktop.
Save hunterbridges/ab095066d40f2e1a243e to your computer and use it in GitHub Desktop.
How to connect to Twitch with an IRC client (As of Oct 2015)

HOWTO

Connect to Twitch.tv chat with an IRC client

  1. Visit this website and get an OAuth Token for your Twitch account.
  2. Add a server to your IRC client with this configuration, using your OAuth Token as the server password. Make sure it is not using SSL.
{
  address = "irc.twitch.tv";
  chatnet = "Twitch";
  port = "6667";
  password = "<YOUR OAUTH TOKEN>";
  use_ssl = "no";
  ssl_verify = "no";
  autoconnect = "yes";
}
  1. A recent update to Twitch's IRC implementation requires using the IRCv3 "membership" capability in order to subscribe to channel updates. If you don't configure your client to use this capability, you will not see channel members or incoming messages. In order to use the membership capability, your client needs to send this raw command to the IRC server automatically after connecting:
CAP REQ :twitch.tv/membership

In irssi, you can use the autosendcmd configuration on the chatnet with the /quote command.

Twitch = {
  type = "IRC";
  nick = "your_twitch_username";
  autosendcmd = "/quote CAP REQ :twitch.tv/membership";
};
  1. Connect to the server and you can now join stream chat rooms. The rooms are titled # followed by the streamer's username in lowercase. So if your name was StreamLord you would want to join #streamlord. You may have issues receiving channel updates if you use capitalized variants.
@hasteur
Copy link

hasteur commented Oct 25, 2017

Just a FYI: Per https://blog.bashtech.net/a-guide-to-twitch-irc/ you can use SSL to conenct to twitch over SSL (probably a good thing since you're transmitting an oauth key). It works and I'm liking it better.

@image28
Copy link

image28 commented Jul 24, 2021

haha

@koutoftimer
Copy link

@hasteur broken link

Error 502 Ray ID: 6746b522182b432d • 2021-07-25 16:19:02 UTC
Bad gateway

Copy link

ghost commented Jul 9, 2022

You can use SSL and have it verified if you connect to irc.chat.twitch.tv instead

@hunterbridges
Copy link
Author

wow this is old… not sure if this guide is even accurate anymore, I should probably just delete it

@shmup
Copy link

shmup commented Aug 5, 2022

@hunterbridges , it is very accurate. It works great. Here is my complete example which I've just tested on irssi, using SSL:

Get your oauth token here: https://twitchapps.com/tmi/

Server block

server = {
    address = "irc.chat.twitch.tv";
    chatnet = "twitch";
    port = "6697";
    password = "oauth:changeme";
    use_ssl = "yes";
    ssl_verify = "yes";
    autoconnect = "no";
}

Chatnet block

chatnets = {
  twitch = {
    type = "IRC";
    nick = "your_twitch_username";
  };
}

I like to /connect twitch and /disconnect twitch as necessary, but if you're dedicated, just set autoconnect = "yes".

@hunterbridges
Copy link
Author

alright then, if it works it works!

@shmup
Copy link

shmup commented Aug 6, 2022

I am curious, though too lazy to test, if the CAP REQ is necessary when using the SSL method. By the way everyone, use the SSL method as per my comment.

Edit: Updated my example above, as you don't need autosendcmd = "/quote CAP REQ :twitch.tv/membership";

@loopedice
Copy link

@shmup you know why tags aren't showing in the logs/window even after requesting the CAP? https://dev.twitch.tv/docs/irc/tags/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment