- Saved searches
- Use saved searches to filter your results more quickly
- License
- xenova/twitch-chat-irc
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- twitch-chat-irc 0.0.4
- Навигация
- Ссылки проекта
- Статистика
- Метаданные
- Сопровождающие
- Классификаторы
- Описание проекта
- Twitch Chat IRC
- Setup
- Requirements:
- Authentication
- Command line:
- Usage
- Examples
- Receiving messages
- Example outputs
- Sending messages
- Python module
- Importing the module
- Подробности проекта
- Ссылки проекта
- Статистика
- Метаданные
- python-twitch-irc
- Installation
- Usage
- Twitch
- Rate Limiting
- Basic Usage
- Twitch IRC functionality
- Twitch IRC Callbacks
- Building
- Testing
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A simple tool used to send and receive Twitch chat messages over IRC with python web sockets.
License
xenova/twitch-chat-irc
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
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.
- This tool was created in a Python 3 environment.
- Run pip install -r requirements.txt to ensure you have the necessary dependencies.
If you intend to send messages, you will require authentication.
- Go to https://twitchapps.com/tmi/
- Click «Connect».
- Log in with Twitch.
- Copy the generated oath token. Now, there are 2 ways to proceed:
- (Recommended) Create a file called .env and save your credentials here as:
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)
1. Output messages from a livestream to standard output
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:
[] :
3. Set a timeout (close connection if no message has been sent in a certain time)
python twitch_chat_irc.py -timeout -output
There are other options, such as message_timeout and buffer_size , but these normally do not need to be changed. See above for a description of all options.
4. Set a maximum number of messages to read (close connection once limit has been reached)
python twitch_chat_irc.py -message_limit -output
python twitch_chat_irc.py -output example.json
python twitch_chat_irc.py -output example.csv
python twitch_chat_irc.py -output example.txt
This will open an interactive session which allows you to send messages to the specified channel.
1. Send messages to a channel (authentication via .env)
python twitch_chat_irc.py --send
2. Send messages to a channel (authentication via arguments)
python twitch_chat_irc.py --send -username -oauth
This allows for both receiving and sending of messages
1. Start a connection with Twitch chat using credentials in .env (if any)
connection = twitch_chat_irc.TwitchChatIRC()
2. Start a connection with Twitch chat using credentials
connection = twitch_chat_irc.TwitchChatIRC('username','oauth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
The listen method returns a list when a KeyboardInterrupt is fired, or when a timeout/limit has been reached. The arguments shown below can be used together to form more complex method calls.
1. Get a list of messages from a channel
messages = connection.listen('channel_name')
2. Get a list of messages from a channel, stopping after not getting a message for 30 seconds
messages = connection.listen('channel_name', timeout=30)
3. Get a list of messages from a channel, stopping after getting 100 messages
messages = connection.listen('channel_name', message_limit=100)
4. Write messages from a channel to a file
connection.listen('channel_name', output='file.txt')
5. Set a callback function to be fired each time a message is received
def do_something(message): print(message) connection.listen('channel_name', on_message=do_something)
The send method allows for messages to be sent to different channels. This method requires valid authentication to be provided, otherwise an exception will be called.
message = 'Hello world!' connection.send('channel_name', message)
The close_connection method closes the connection with Twitch chat. No futher messages can be received or sent now.
About
A simple tool used to send and receive Twitch chat messages over IRC with python web sockets.
twitch-chat-irc 0.0.4
A simple tool used to send and receive Twitch chat messages over IRC with python web sockets.
Навигация
Ссылки проекта
Статистика
Метаданные
Лицензия: MIT License (MIT)
Автор: xenova, scmanjarrez
Метки python, twitch, irc, websockets
Требует: Python >= 3.7
Сопровождающие
Классификаторы
Описание проекта
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.
- Install via pip with pip install twitch-chat-irc
- Or install manually with pip install .
Authentication
If you intend to send messages, you will require authentication.
- Go to https://twitchapps.com/tmi/
- Click «Connect».
- Log in with Twitch.
- Copy the generated oath token. Now, there are 2 ways to proceed:
- (Recommended) Create a file called .env and save your credentials here as:
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
2. Output messages from a livestream to a file
python -m twitch_chat_irc -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:
[] :
3. Set a timeout (close connection if no message has been sent in a certain time)
python -m twitch_chat_irc -timeout -output
There are other options, such as message_timeout and buffer_size , but these normally do not need to be changed. See above for a description of all options.
4. Set a maximum number of messages to read (close connection once limit has been reached)
python -m twitch_chat_irc -message_limit -output
Example outputs
python -m twitch_chat_irc -output example.json
python -m twitch_chat_irc -output example.csv
python -m twitch_chat_irc -output example.txt
Sending messages
This will open an interactive session which allows you to send messages to the specified channel.
1. Send messages to a channel (authentication via .env)
python -m twitch_chat_irc --send
2. Send messages to a channel (authentication via arguments)
python -m twitch_chat_irc --send -username -oauth
Python module
Importing the module
This allows for both receiving and sending of messages
1. Start a connection with Twitch chat using credentials in .env (if any)
The listen method returns a list when a KeyboardInterrupt is fired, or when a timeout/limit has been reached. The arguments shown below can be used together to form more complex method calls.
1. Get a list of messages from a channel
The send method allows for messages to be sent to different channels. This method requires valid authentication to be provided, otherwise an exception will be called.
1. Send a message
The close_connection method closes the connection with Twitch chat. No futher messages can be received or sent now.
1. Close a connection
Подробности проекта
Ссылки проекта
Статистика
Метаданные
Лицензия: MIT License (MIT)
Автор: xenova, scmanjarrez
Метки python, twitch, irc, websockets
Требует: Python >= 3.7
python-twitch-irc
python-twitch-irc is a layer of logic which takes the Pydle package and provides (or modifies existing) logic to handle Twitch IRC pecularities.
Installation
python-twitch-irc can be installed via pip install python-twitch-irc
Usage
python-twitch-irc is a layer which sits above Pydle so if documentation is lacking, refer to Pydle documentation. Twitch IRC is not fully compliant with RFC1459 and later, so some behaviors may not function as expected (such as who/whois, nick, etc).
Twitch
Utilizing this library requires a Twitch account and a token generated for that account. A token can be generated via TwitchApps. Note that the generated token has the prefix ‘oauth’ which should be removed before use.
Rate Limiting
TwitchIrc does not provide rate limiting. To see rates and limits, see Twitch Irc Guide.
Basic Usage
TwitchIrc is expected to be used as a base class.
Most of the Basic IRC functionality can be found via Pydle Documentation. It shold be noted that not all functionality provided by Pydle is compatible with Twitch IRC.
Twitch IRC functionality
TwitchIrc provides the following additional functionality. These functions may or may not require permissioning per channel.
Twitch IRC Callbacks
TwitchIRC provides callbacks which can be overriden. Their purpose/meaning can be divined from Twitch Irc Guide.
By default, capabilities are enabled. To disable capabilities, override the following functions and return False :
Development environment utilizes docker and docker-compose for building and testing the library.
Building
The python_twitch_irc library can be build via ./build.sh
Testing
The unit tests can be run via ./test.sh . Local changes can be tested without rebuilding the test container via ./test-dev.sh but requires that the initial test container be built.