Skip to content

Instantly share code, notes, and snippets.

@3ventic
Last active May 5, 2022 14:39
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3ventic/0c3282e4b62695da7203 to your computer and use it in GitHub Desktop.
Save 3ventic/0c3282e4b62695da7203 to your computer and use it in GitHub Desktop.
Twitch IRC v3

Twitch IRC v3 unofficial documentation

Commands

> CAP REQ :twitch.tv/commands
< :tmi.twitch.tv CAP * ACK :twitch.tv/commands

Enables USERSTATE, HOSTTARGET and CLEARCHAT raw commands.

HOSTTARGET

Host starts message:

< :tmi.twitch.tv HOSTTARGET #hosting_channel :target_channel [number]

Host stops message:

< :tmi.twitch.tv HOSTTARGET #hosting_channel :- [number]

Number is assumed to be the number of viewers watching the host.

CLEARCHAT

Username is timed out on channel:

< :tmi.twitch.tv CLEARCHAT #channel :username

Chat is cleared on channel:

< :tmi.twitch.tv CLEARCHAT #channel

USERSTATE

Use with tags CAP to get anything out of it.

:tmi.twitch.tv USERSTATE #notventic

Tags

Adds IRC v3 message tags to PRIVMSG and USERSTATE (if enabled with commands CAP)

PRIVMSG

Example message:

@color=#1E0ACC;display-name=3ventic;emotes=25:0-4,12-16/1902:6-10;subscriber=0;turbo=1;user-type=mod;user_type=mod :3ventic!3ventic@3ventic.tmi.twitch.tv PRIVMSG #notventic :Kappa Keepo Kappa
  • color is hexadecimal RGB color code, which can be empty if the user never set it.
  • display-name is the user's display name, escaped as described as described in the IRCv3 spec
  • emotes contains information to replace text in the message with the emote images and can be empty. The format is as follows:
    • emote_id:first_index-last_index,another_first-another-last/another_emote_id:first_index-last_index
    • emote_id is the number to use in this URL: http://static-cdn.jtvnw.net/emoticons/v1/:emote_id/:size (size is 1.0, 2.0 or 3.0)
    • Emote indexes are simply character indexes. \000ACTION does not count and indexing starts from the first character that is part of the user's "actual message". In the example message, the first Kappa (emote id 25) is from character 0 (K) to character 4 (a), and the other Kappa is from 12 to 16.
  • subscriberand turbo are either 0 or 1 depending on whether the user has sub or turbo badge or not.
  • user-type is either empty, mod, global_mod, admin or staff.

USERSTATE

USERSTATE is sent when joining a channel and every time you send a PRIVMSG to a channel. Example:

@color=#1E0ACC;display-name=3ventic;emote-sets=0,12239,2126,237,33,366,4578,469,793,9400;emotesets=0,12239,2126,237,33,366,4578,469,793,9400;subscriber=0;turbo=1;user-type=mod;user_type=mod :tmi.twitch.tv USERSTATE #gophergaming

The tags here work the same as in PRIVMSG, except some are missing. emote-sets contains your emote set, which you can use to request https://api.twitch.tv/kraken/chat/emoticon_images?emotesets=[straight from the emote-sets tag]. It should not be empty since 0 is the global emotes' emote set.

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