# Twitch Chat IRC A simple tool used to send and receive Twitch chat messages over IRC with python web sockets. Receiving does not require authentication, while sending does. ## Setup ### Requirements: * This tool was created in a Python 3 environment. * Run `pip install -r requirements.txt` to ensure you have the necessary dependencies. ### Authentication If you intend to send messages, you will require authentication. 1. Go to https://twitchapps.com/tmi/ 2. Click "Connect". 3. Log in with Twitch. 4. Copy the generated oath token. Now, there are 2 ways to proceed: - (Recommended) Create a file called `.env` and save your credentials here as: > NICK=x
PASS=y replacing `x` and `y` with your username and oauth token respectively.
See `example.env` for an example. - Pass your credentials as function/command line arguments. See below for examples. ## Command line: ### Usage ``` usage: twitch_chat_irc.py [-h] [-timeout TIMEOUT] [-message_timeout MESSAGE_TIMEOUT] [-buffer_size BUFFER_SIZE] [-message_limit MESSAGE_LIMIT] [-username USERNAME] [-oauth OAUTH] [--send] [-output OUTPUT] channel_name Send and receive Twitch chat messages over IRC with python web sockets. For more info, go to https://dev.twitch.tv/docs/irc/guide positional arguments: channel_name Twitch channel name (username) optional arguments: -h, --help show this help message and exit -timeout TIMEOUT, -t TIMEOUT time in seconds needed to close connection after not receiving any new data (default: None = no timeout) -message_timeout MESSAGE_TIMEOUT, -mt MESSAGE_TIMEOUT time in seconds between checks for new data (default: 1 second) -buffer_size BUFFER_SIZE, -b BUFFER_SIZE buffer size (default: 4096 bytes = 4 KB) -message_limit MESSAGE_LIMIT, -l MESSAGE_LIMIT maximum amount of messages to get (default: None = unlimited) -username USERNAME, -u USERNAME username (default: None) -oauth OAUTH, -password OAUTH, -p OAUTH oath token (default: None). Get custom one from https://twitchapps.com/tmi/ --send send mode (default: False) -output OUTPUT, -o OUTPUT output file (default: None = print to standard output) ``` ### Examples #### Receiving messages ##### 1. Output messages from a livestream to standard output ``` python twitch_chat_irc.py ``` ##### 2. Output messages from a livestream to a file ``` python twitch_chat_irc.py -output ``` If the file name ends in `.json`, the array will be written to the file in JSON format. Similarly, if the file name ends in `.csv`, the data will be written in CSV format.
Otherwise, the chat messages will be outputted to the file in the following format:
`[