Page 2 of 2

Re: BATC Streamer - Chat Engine

Posted: Sun May 15, 2022 2:57 pm
by M0DTS
Here's the basic python script to receive messages from a certain stream using python.
This is not yet an OBS script, I'll get there later but gives the very simple interface to the messages needed.

I have assumed this is intended for a windows system with OBS but i may be mistaken...
i also believe you need python v3.6 for OBS, dont think it works with the latest version.

You need to install socketio library for python with this command at windows command prompt:
python -m pip install python-engineio==3.14.2 python-socketio==4.6.0

(the default library does not connect for some reason)
Change room=gb3km to whatever stream you like, note lower case.

Then here is the example script to connect and await messages:

Code: Select all


import socketio
import time

sio = socketio.Client()

@sio.on('message')
def message(data):
    print('received message',data)   #example message format in dict: {'time': '2022-05-15T14:36:19.517Z', 'name': 'M0DTS', 'message': 'test'}

sio.connect("https://batc.org.uk/?room=gb3km",{},transports=None,socketio_path='live-chat/socket.io')
sio.wait()

Example output:

Code: Select all

C:\Users\rob>python c:\python_code\chat.py
received message {'time': '2022-05-15T14:52:48.626Z', 'name': 'M0DTS', 'message': 'did we try 3cm before?'}