diff --git a/.gitignore b/.gitignore index f2a1fb6..ce527d2 100644 --- a/.gitignore +++ b/.gitignore @@ -128,5 +128,12 @@ dmypy.json # Pyre type checker .pyre/ +.vscode/ + # toml config -config.toml \ No newline at end of file +config.toml + +# test +quick.py +logging.json +tests/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..126db22 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,30 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [Unreleased] + +- [x] + +## [1.0.0] - 2023-06-28 + +The only potential breaking change, a new error class raised if the initial connection fails. + + +### Added + +- tomllib/tomli now lazy loaded in _token_from_toml(). Allows possibility to run package without tomli. +- module level logger +- debug example +- raw kwarg for receiving the raw json data. +- `Path.home() / ".config" / "streamlabsio" / "config.toml"` added to config.toml filepaths. + +### Changed + +- Python minimum required version changed to 3.8 +- new error class + - `SteamlabsSIOConnectionError` raised on a connection error diff --git a/README.md b/README.md index 30160af..5803687 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ - A Streamlabs Socket API key. - You can acquire this by logging into your Streamlabs.com dashboard then `Settings->Api Settings->API Tokens` +- Python 3.8 or greater + ### How to install using pip ``` @@ -37,8 +39,8 @@ Example `__main__.py`: import streamlabsio -def on_twitch_event(event, msg): - print(f"{event}: {msg.attrs()}") +def on_twitch_event(event, data): + print(f"{event}: {data.attrs()}") def main(): @@ -58,6 +60,14 @@ if __name__ == "__main__": From the [SocketIO docs](https://python-socketio.readthedocs.io/en/latest/client.html#managing-background-tasks), `client.sio.wait()` may be used if your application has nothing to do in the main thread. +### Client class +`streamlabsio.connect(token="", raw=False)` + +The following keyword arguments may be passed: + +- `token`: str Streamlabs SocketIO api token. +- `raw`: boolean=False Receive raw json objects. + ### Attributes For event messages you may inspect the available attributes using `attrs()`. @@ -69,6 +79,14 @@ def on_twitch_event(event, msg): print(f"{event}: {msg.attrs()}") ``` +### Errors + +- `SteamlabsSIOConnectionError`: Exception raised when connection errors occur + +### Logging + +To view raw incoming event data set logging level to DEBUG. Check `debug` example. + ### Official Documentation - [Streamlabs Socket API](https://dev.streamlabs.com/docs/socket-api)