Since They Change The Way This Program Listen For Donation.
Want to help me? Sure i appreciate!
An easy way to listen for Trakteer donation in Python
To install this package, you can easily use pip!
pip install trakteerdonate
Or,
pip install git+https://github.com/then77/trakteerdonate
- First open your Trakteer and go to Stream Overlay (here)
- On the Widget URL, copy the key, and the hash
- Create a code and import the
Client
function.
from trakteerdonate import Client
client = Client("hash", "streamKey")
# Replace "hash" and "streamKey" with the key you copied before
- Add listener for donation
@client.event
async def on_donation(ws, data):
print("Received donation:")
print(f" - Name: {data.name}")
print(f" - Amount: {data.amount}")
print(f" - Message: {data.message}")
- Last, add this code To the bottom of the code and run!
client.start()
The reason it should be placed on the bottom because its a blocking function.
from trakteerdonate import Client
client = Client("hash", "streamKey")
@client.event
async def on_connect(ws):
print("Connected to Trakteer!")
@client.event
async def on_donation(ws, data):
print("Received donation:")
print(f" - Name: {data.name}")
print(f" - Amount: {data.amount}")
print(f" - Message: {data.message}")
client.start()
Wait, do you have another API to interact instead of only listening donation?
Currenly no since i dont have much time to do that. But, i found another cool project that can do something like that here. Even though it uses Javascript, its still awesome.
Since this package use websocket to communicate, some host like Replit
may not allow this protocol. But, you still can run on your local pc or another host that support it, or you can use alternative library i mentioned above since it doesn't use websocket thing.
This repository and its code is under the MIT License. Read more here.