Twitch.tv support
MasterLogick edited this page May 5, 2019
·
5 revisions
Twitch.tv runs a custom IRC server that doesn't support the full IRC protocol. This has required some tweaks in PircBotX 2.1, see the DevVersion page for how to get it
First to connect you need an OAuth token as specified here: https://dev.twitch.tv/docs/irc/guide/#connecting-to-twitch-irc
The connect section translates to
new Configuration.Builder()
.setAutoNickChange(false) //Twitch doesn't support multiple users
.setOnJoinWhoEnabled(false) //Twitch doesn't support WHO command
.setCapEnabled(true)
.addCapHandler(new EnableCapHandler("twitch.tv/membership")) //Twitch by default doesn't send JOIN, PART, and NAMES unless you request it, see https://dev.twitch.tv/docs/irc/guide/#twitch-irc-capabilities
.addServer("irc.twitch.tv")
.setName("MyTwitchUsername") //Your twitch.tv username
.setServerPassword("oauth:bigAlphanumericString") //Your oauth password from http://twitchapps.com/tmi
.addAutoJoinChannel("#vgbootcamp") //Some twitch channel
.addListener(new MyListener())
//The rest of your config...
Explained:
- Note: Recently Twitch implemented
CAP LS
sosetCapEnabled(false)
is no longer necessary. -
setOnJoinWhoEnabled(false)
is required as twitch doesn't support the WHO command. This also means every user's getLogin()/getIdent() and getHostname() will be null until they talk, because that's the first time their full hostmask is sent. From Issue #248 -
.addCapHandler(new EnableCapHandler("twitch.tv/membership"))
is recommended as twitch by default doesn't send JOIN, PART, and NAMES responses. This means the channel will confusingly only have 1 user: the bot itself.
Optionally you can enable IRCv3 Message Tags as defined here ( https://dev.twitch.tv/docs/irc/tags/ ) for more information about the user with:
.addCapHandler(new EnableCapHandler("twitch.tv/tags"))
The tag data is available in MessageEvent.getTags()