Metadata-Version: 2.3
Name: aips-chatwork
Version: 0.1.0
Summary: Lightweight Python client for the Chatwork API
Author: looreypun
Author-email: looreypun <looreyhunks@gmail.com>
Requires-Dist: httpx>=0.28.1
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# AIPS Chatwork

Lightweight Python client for sending messages and formatted alerts to the Chatwork API.

## Requirements

- Python 3.12+

## Installation

Using `uv`:

```bash
uv add "aips-chatwork @ git+ssh://git@github.com/YOUR_ORG/aips-chatwork.git@v0.1.0"
```

## Usage

### Send a Message

```python
from aips_chatwork import ChatworkClient

with ChatworkClient(
    api_token="your-api-token",
) as client:
    client.send_message(
        room_id="123456789",
        message="Hello from AIPS",
    )
```

### Send an Alert

Server or application information can be included in formatted alert messages.

```python
from aips_chatwork import ChatworkClient

with ChatworkClient(
    api_token="your-api-token",
    server_name="media-server-01",
    server_ip="10.0.1.25",
) as client:
    client.send_alert(
        room_id="123456789",
        title="S3 Upload Failed",
        message=(
            "Camera: 3C6AD2F790C6\n"
            "File: 14-00-00-123456_300000ms.mp4\n"
            "Error: Connection timeout"
        ),
    )
```

The alert is displayed in Chatwork with the source information as the header:

```text
MEDIA-SERVER-01 | 10.0.1.25

【S3 Upload Failed】

Camera: 3C6AD2F790C6
File: 14-00-00-123456_300000ms.mp4
Error: Connection timeout
```

## Environment Variables

API tokens and room IDs should be stored in environment variables rather than source code.

Example:

```dotenv
CHATWORK_API_TOKEN=your-api-token
CHATWORK_ROOM_ID=123456789
```

Usage:

```python
import os

from aips_chatwork import ChatworkClient

with ChatworkClient(
    api_token=os.environ["CHATWORK_API_TOKEN"],
    server_name="media-server-01",
    server_ip="10.0.1.25",
) as client:
    client.send_alert(
        room_id=os.environ["CHATWORK_ROOM_ID"],
        title="Service Error",
        message="An unexpected error occurred.",
    )
```

## Development

Install dependencies:

```bash
uv sync
```

Lint:

```bash
uv run ruff check .
```

Format:

```bash
uv run ruff format .
```

## License

Internal AIPS package.