Metadata-Version: 2.4
Name: greenheat-py
Version: 0.1.0
Summary: An async Python client for GreenHeat, a Twitch stream click/heatmap overlay extension
Author-email: WolfwithSword <12175651+WolfwithSword@users.noreply.github.com>
Maintainer-email: WolfwithSword <12175651+WolfwithSword@users.noreply.github.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/WolfwithSword/GreenHeatPy
Project-URL: Documentation, https://heat.prod.kr/
Project-URL: Issues, https://github.com/WolfwithSword/GreenHeatPy/issues
Keywords: greenheat,twitch,heatmap,websocket,asyncio,extension
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: websockets>=13.0
Requires-Dist: truststore>=0.10.4
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: pytest-asyncio>=0.24; extra == "test"

# greenheat-py

A Python library for [GreenHeat](https://heat.prod.kr/), letting you receive viewer clicks, hovers and drags on your Twitch stream as async events.

## Install

```sh
pip install greenheat-py
```

## Usage

```python
import asyncio

from greenheat import GreenHeatClient
from greenheat.models import GreenHeatMessage
from greenheat.enums import GreenHeatButtonType, GreenHeatEventType


async def on_message(message: GreenHeatMessage):
    if message.type != GreenHeatEventType.CLICK:
        return

    click_action = ""
    if message.button == GreenHeatButtonType.LEFT and message.shift:
        click_action = "shift + left click"
    elif message.button == GreenHeatButtonType.RIGHT and (message.ctrl or message.alt):
        click_action = "ctrl/alt + right click"

    user = message.twitch_id or "anonymous"

    x, y = message.screen_position(1920, 1080)
    print(f"{user} clicked at ({x}, {y}) [{click_action}]")

    if message.is_in_box(0.0, 0.0, 0.5, 0.5):
        print("...in the top-left quadrant of the screen")


async def main():
    async with GreenHeatClient("wolfwithsword", on_message) as client:
        await asyncio.Event().wait()

    # Alternative
    # await client.run()

asyncio.run(main())
```

You can also run the client with `await client.run()`, which blocks until `client.close()` is called or the program is exited.

There's also a small command line tool that logs events for a channel:

```sh
greenheat --channel wolfwithsword --debug
```

## License

MIT
