This file contains the python code used to interface with the Twitch chat. Twitch chat is IRC-based, so it is basically an IRC-bot, but with special features for Twitch, such as congestion control built in.

class, oauth, verbose=False)[source]

The TwitchChatStream is used for interfacing with the Twitch chat of a channel. To use this, an oauth-account (of the user chatting) should be created. At the moment of writing, this can be done here:

  • username (string) – Twitch username
  • oauth (string) – oauth for logging in (see
  • verbose (boolean) – show all stream messages on stdout (for debugging)

Connect to Twitch


Join a different chat channel on Twitch. Note, this function returns immediately, but the switch might take a moment

Parameters:channel – name of the channel (without #)

Send a chat message to the server.

Parameters:message – String to send (don’t use n)

Call this function to process everything received by the socket This needs to be called frequently enough (~10s) Twitch logs off users not replying to ping commands.

Returns:list of chat messages received. Each message is a dict with the keys [‘channel’, ‘username’, ‘message’]