2022-11-13 10:07:08 +00:00
|
|
|
import streamlabsio
|
|
|
|
|
|
|
|
|
2023-06-28 02:48:12 +01:00
|
|
|
def on_youtube_event(event, data):
|
2025-01-20 13:32:36 +00:00
|
|
|
print(f'{event}: {data.attrs()}')
|
2022-11-13 10:07:08 +00:00
|
|
|
|
|
|
|
|
2023-06-28 02:48:12 +01:00
|
|
|
def on_twitch_event(event, data):
|
2025-01-20 13:32:36 +00:00
|
|
|
if event == 'follow':
|
|
|
|
print(f'Received follow from {data.name}')
|
|
|
|
elif event == 'bits':
|
|
|
|
print(f'{data.name} donated {data.amount} bits! With message: {data.message}')
|
|
|
|
elif event == 'donation':
|
2023-06-28 02:48:12 +01:00
|
|
|
print(
|
2025-01-20 13:32:36 +00:00
|
|
|
f'{data.name} donated {data.formatted_amount}! With message: {data.message}'
|
2023-06-28 02:48:12 +01:00
|
|
|
)
|
2022-11-13 10:07:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2022-11-13 14:41:03 +00:00
|
|
|
# read token from config.toml
|
2022-11-13 10:07:08 +00:00
|
|
|
with streamlabsio.connect() as client:
|
2025-01-20 13:32:36 +00:00
|
|
|
client.obs.on('streamlabs', on_twitch_event)
|
|
|
|
client.obs.on('twitch_account', on_twitch_event)
|
|
|
|
client.obs.on('youtube_account', on_youtube_event)
|
2022-11-13 10:07:08 +00:00
|
|
|
|
2022-11-13 14:41:03 +00:00
|
|
|
# run for 30 seconds then disconnect client from server
|
|
|
|
client.sio.sleep(30)
|
2022-11-13 10:07:08 +00:00
|
|
|
|
|
|
|
|
2025-01-20 13:32:36 +00:00
|
|
|
if __name__ == '__main__':
|
2022-11-13 10:07:08 +00:00
|
|
|
main()
|