Metadata-Version: 2.1
Name: aiotraq-bot
Version: 0.2.3
Summary: Async ready traQ Bot library
Home-page: https://github.com/toshi-pono/aiotraq
License: MIT
Keywords: traQ,bot,async,aiotraq
Author: toshi00
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: fastapi (>=0.100.0)
Requires-Dist: uvicorn[standard] (>=0.12.0)
Project-URL: Repository, https://github.com/toshi-pono/aiotraq
Project-URL: Source Code, https://github.com/toshi-pono/aiotraq/tree/main/libs/bot
Description-Content-Type: text/markdown

# AiotraQ-Bot

Async ready traQ Bot library written in Python.

[![PyPI - Version](https://img.shields.io/pypi/v/aiotraq-bot)](https://pypi.org/project/aiotraq-bot/)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toshi-pono/aiotraq/blob/main/LICENSE)
[![CI](https://github.com/toshi-pono/aiotraq/actions/workflows/ci.yml/badge.svg)](https://github.com/toshi-pono/aiotraq/actions/workflows/ci.yml)

## Requirements

AiotraQ-Bot は以下のライブラリを使用しています。

- [FastAPI](https://fastapi.tiangolo.com/): サーバーの実装
- [Uvicorn](https://www.uvicorn.org/): サーバーの実行
- [Pydantic](https://docs.pydantic.dev/latest/): データのバリデーション

## Installation

```bash
pip install aiotraq-bot
```

## Usage

`TraqHttpBot` を使って http bot を作成することができます。

`traQ->BOTサーバー`へのイベント受け取り部分を補助します。
`BOTサーバー->traQ`へのイベント送信は [AiotraQ](https://github.com/toshi-pono/aiotraq/tree/main/libs/aiotraq)、[AiotraQ-Message](https://github.com/toshi-pono/aiotraq/tree/main/libs/message) 等を利用してください。

```python
import os
from aiotraq_bot import TraqHttpBot

bot = TraqHttpBot(verification_token=os.getenv("BOT_VERIFICATION_TOKEN"))

@bot.event()
async def on_message(payload: MessageCreatedPayload):
    print(payload)

if __name__ == "__main__":
  bot.run()
```

### Event handler の登録

イベントの登録は `@bot.event()` デコレータを使って行うことができます。
event の引数として対象のイベントを指定するか、関数の型ヒントを使って指定することができます。

`MESSAGE_CREATED` イベントを型ヒントを使って指定する場合

```python
@bot.event()
async def on_message(payload: MessageCreatedPayload):
    print(payload)
```

`MESSAGE_CREATED`イベントを引数を用いて指定する場合

```python
@bot.event("MESSAGE_CREATED")
async def on_message(payload):
    print(payload)
```

詳細は [ドキュメント|Bot サーバーの作成](https://toshi-pono.github.io/aiotraq/docs/intro/)を参照してください。

## Acknowledgements

This project is inspired by [python-traq-bot](https://github.com/eyemono-moe/python-traq-bot).

## License

This project is licensed under the terms of the MIT license.

