Accessing chat information

I want to be able to access the information in the chat such as the usernames, time stamps, the colour of the user and their message. There is a bot that does all that which can be found here moobot. They have access to the chat to do polling so it should be possible right?

I searched the API with no luck. I could only find things that give you the list of users in the chat but not all the information that I require. Could someone help point me in the right direction please?

Bots such as moobot are connected to the chat through a pseudo-IRC called TMI (Twitch Message Interface).

Once connected to the TMI you can access a bunch of chat data, such as users, who’s +o (mods, broadcaster, staff and admins) and chat lines.

Extra data is sent when you connect and send the “JTVCLIENT” command (“TWITCHCLIENT 1” or “TWITCHCLIENT 2” might also work). (returned is USERCOLOR, SPECIALUSER and EMOTESET) It’s not entirely reliable but it works somewhat.

Just to add clarification in case others come here looking for information:

JTVCLIENT is the same as TWITCHCLIENT, but it’s best to use TWITCHCLIENT going forward.

TWITCHCLIENT by itself is the same as TWITCHCLIENT 1, and allows you to get userdata PMed to you by a user named “jtv.”

TWITCHCLIENT 2, however, is what the Twitch website uses nowadays. The big difference is that TWITCHCLIENT 2 prevents you from seeing channel joins and parts.

It is rumored there will eventually be a TWITCHCLIENT 3 that will change userdata to be PRIVMSG’d to the channel it originates, rather than by private message, providing channel context to the userdata. It is unknown if Twitch will ever implement any type of channel context to userdata, but it is heavily desired.

Any idea on when TWITCHCLIENT 3 might be available?
As of now, the only way to know the scope of jtv’s messages is to make a new connection for each channel you want to monitor.

TWITCHCLIENT 3 has been implemented.

2 Likes

Do we have some documentation for this or is it detective funtimes?

No official documentation, based on my testing:

  • USERCOLOR, SPECIALUSER (sub/turbo), EMOTESET, CLEARCHAT, and most/all command responses are sent from jtv as channel messages.
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :SPECIALUSER george subscriber
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :USERCOLOR george #000000
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :EMOTESET george [5,27]
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :CLEARCHAT kappa1
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :You have banned kappa1 for 600 seconds.
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :This room is now in slow mode. You may send messages every 120 seconds
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :This room is no longer in slow mode.
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :This room is now in subscribers-only mode.
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :This room is no longer in subscribers-only mode.
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :The moderators of this room are: 
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :This room is now in r9k mode. See http://bit.ly/bGtBDf
:jtv!jtv@jtv.tmi.twitch.tv PRIVMSG #bwana :This room is no longer in r9k mode.
  • SPECIALUSER (admin/staff) are still private messages
  • No JOIN/PART (same as TC 2)
  • twitchnotify is now only sent to TC 3 users. (possibly a bug)

How do you think we should go about fetching users in a channel with TWITCHCLIENT 3? I know there is the API, but is there a way via IRC?

For normal IRC you are best just sticking with no client type at all or TWITCHCLIENT 1. Missing twitchnotify appears to be bug (per Xangold).

This is really bugging me at the moment, was wondering why my bot didnt collect subscriber messages again and just stumbled upon this. Has this been confirmed a bug yet or does it work as expected?

I made a quick node script that sends a bot into desired channels and parses out the messages from users, stores them into a mongodb and hosts an api of the data to be used however you wish. I don’t know if this is what you are looking for or not; but here ya go: https://github.com/adrazich/Twitch-Plays

1 Like