A Python library for Twitch's WebSocket EventSub integration.
Project description
Twitchify
Python library for Twitch's WebSocket EventSub integration.
Features
- Comprehensive support for WebSocket EventSub, providing real-time Twitch event notifications.
- User-friendly interfaces for seamless integration.
- Built-in support for type hinting, ensuring code clarity and maintainability.
Installation
You can install Twitchify using pip:
# Windows
py -3 -m pip install -U twitchify
# Linux/macOS
python3 -m pip install -U twitchify
Quick Example
from twitch import Client
from twitch.user import Follower
client = Client(client_id="YOUR_CLIENT_ID")
@client.event
async def on_ready():
"""
Event handler triggered when the client is ready to start processing events.
"""
print("Ready as %s" % client.user.display_name)
@client.event
async def on_follow(user: Follower):
"""
Event handler triggered when a user follows the channel.
"""
print("%s just followed you!" % user.display_name)
# Run the client with your user access token.
client.run(access_token="YOUR_ACCESS_TOKEN")
With built-in Authorization
from twitch import Client
from twitch.user import Follower
# Initialize the Twitch client with your client ID and client secret.
client = Client(client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET")
# Generate the authorization URL for the Twitch client.
# The user should visit the provided URL to authorize the app.
auth = client.auth()
@client.event
async def on_ready():
"""
Event handler triggered when the client is ready to start processing events.
"""
print("Ready as %s" % client.user.display_name)
@client.event
async def on_follow(user: Follower):
"""
Event handler triggered when a user follows the channel.
"""
print("%s just followed you!" % user.display_name)
# You can store the access token and refresh token for future use, so you don't have to authorize again.
client.run(access_token=auth.access_token, refresh_token=auth.refresh_token)
Please refer to the Documentation or Examples for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
twitchify-1.2.2.tar.gz
(33.0 kB
view hashes)
Built Distribution
twitchify-1.2.2-py3-none-any.whl
(67.1 kB
view hashes)
Close
Hashes for twitchify-1.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1adc4b859b85bb515698f3f692a3eceac7efffae124f113139749bcc790b2de1 |
|
MD5 | be8e1aad16c8fb29d1d62238d93473cf |
|
BLAKE2b-256 | 038101d8946b3938c7383fca27e128330d14e7ea886fe6ea0d67045d73931e97 |