From 82ddbacd7dd3bd7879ed79c54afd4bf978dd8b1d Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Tue, 26 Jul 2022 03:31:32 +0100 Subject: [PATCH] send event name to callback add requirements to readme. --- README.md | 6 ++++++ obsstudio_sdk/callback.py | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ff0d837..16ec141 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ This is a wrapper around OBS Websocket. Not all endpoints in the official documentation are implemented. But all endpoints in the Requests section is implemented. You can find the relevant document using below link. [obs-websocket github page](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#Requests) +## Requirements + +- [OBS Studio](https://obsproject.com/) +- [OBS Websocket v5 Plugin](https://github.com/obsproject/obs-websocket/releases/tag/5.0.0) +- Python 3.11 or greater + ### How to install using pip ``` diff --git a/obsstudio_sdk/callback.py b/obsstudio_sdk/callback.py index 24732c5..fc2c445 100644 --- a/obsstudio_sdk/callback.py +++ b/obsstudio_sdk/callback.py @@ -1,4 +1,5 @@ import re +from typing import Callable, Iterable, Union class Callback: @@ -28,16 +29,16 @@ class Callback: for fn in self._callbacks: if fn.__name__ == self.to_snake_case(event): if "eventData" in data: - fn(data["eventData"]) + fn(event, data["eventData"]) else: - fn() + fn(event) - def register(self, fns): + def register(self, fns: Union[Iterable, Callable]): """registers callback functions""" try: - iter(fns) - for fn in fns: + iterator = iter(fns) + for fn in iterator: if fn not in self._callbacks: self._callbacks.append(fn) except TypeError as e: