twitchstream.chat¶
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 twitchstream.chat.TwitchChatStream(username, 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: https://twitchapps.com/tmi/
Parameters: - username (string) – Twitch username
- oauth (string) – oauth for logging in (see https://twitchapps.com/tmi/)
- verbose (boolean) – show all stream messages on stdout (for debugging)
- join_channel(channel)[source]¶
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_chat_message(message)[source]¶
Send a chat message to the server.
Parameters: message – String to send (don’t use n)
- twitch_receive_messages()[source]¶
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’]