mirror of
https://github.com/onyx-and-iris/duckypad-twitch.git
synced 2024-11-15 14:30:50 +00:00
34 lines
945 B
Python
34 lines
945 B
Python
|
import slobs_websocket
|
||
|
|
||
|
|
||
|
def ensure_sl(func):
|
||
|
"""ensure a streamlabs websocket connection has been established"""
|
||
|
|
||
|
def wrapper(self, *args):
|
||
|
if self._duckypad.streamlabs_controller.conn.ws is None:
|
||
|
try:
|
||
|
try:
|
||
|
self.connect()
|
||
|
except AttributeError:
|
||
|
self._duckypad.streamlabs_controller.connect()
|
||
|
except slobs_websocket.exceptions.ConnectionFailure:
|
||
|
self._duckypad.streamlabs_controller.conn.ws = None
|
||
|
return
|
||
|
return func(self, *args)
|
||
|
|
||
|
return wrapper
|
||
|
|
||
|
|
||
|
def ensure_obsws(func):
|
||
|
"""ensure an obs websocket connection has been established"""
|
||
|
|
||
|
def wrapper(self, *args):
|
||
|
if self.request is None:
|
||
|
try:
|
||
|
self.obs_connect()
|
||
|
except (ConnectionRefusedError, TimeoutError):
|
||
|
return
|
||
|
return func(self, *args)
|
||
|
|
||
|
return wrapper
|