mirror of
https://github.com/onyx-and-iris/streamlabs-socketio-py
synced 2026-04-07 13:43:30 +00:00
add block_forever example
update example READMEs add script entry point for block_forever example add poe task block-forever
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
## About
|
||||
|
||||
To view the logs emitted by the streamlabsio library simply add the following to your code:
|
||||
This example demonstrates the following:
|
||||
|
||||
```python
|
||||
from loguru import logger
|
||||
|
||||
logger.enable('streamlabsio')
|
||||
```
|
||||
- How to register callback functions for different kinds of events.
|
||||
- How to view the logs emitted by the streamlabsio library.
|
||||
- How to print the attributes of an event data dataclass using the *attrs()* method.
|
||||
- How to use dataclass methods on the dataclasses, this case *asdict*.
|
||||
- How to use {Client}.wait() to block the main thread for a period of time.
|
||||
|
||||
## Configure
|
||||
|
||||
The script expects the Streamlabs token to be loaded into the environment with key `STREAMLABS_TOKEN`.
|
||||
|
||||
If you're running the script with `poetry poe` then poe is configured to load a `.env` file in the root of the repository.
|
||||
If you're running the script with `poetry poe events` then poe is configured to load a `.env` file in the root of the repository.
|
||||
|
||||
## Use
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ logger.enable('streamlabsio')
|
||||
|
||||
|
||||
def on_streamlabs_event(event, data):
|
||||
print(data.attrs())
|
||||
|
||||
match event:
|
||||
case 'donation':
|
||||
print(f'{data.name} donated {data.amount}! With message: {data.message}')
|
||||
@@ -44,7 +46,7 @@ def main():
|
||||
client.obs.on('twitch_account', on_twitch_event)
|
||||
client.obs.on('youtube_account', on_youtube_event)
|
||||
|
||||
client.sio.sleep(30)
|
||||
client.wait(30)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user