Metadata-Version: 2.4
Name: aiotraq-message
Version: 0.2.6
Summary: aiotraq Plugin that supports interactive message sending using Streamlit-style syntax for traQ
License: MIT
License-File: LICENSE
Keywords: traQ,bot,message,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
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: aiotraq (>=0.2.5,<0.3.0)
Requires-Dist: aiotraq-bot (>=0.2.5,<0.3.0)
Requires-Dist: anyio (>=4.14.2,<5)
Requires-Dist: attrs (>=22.2.0)
Requires-Dist: certifi (>=2026.10.19)
Requires-Dist: fastapi (>=0.135.1,<1)
Requires-Dist: h11 (>=0.16.0,<1)
Requires-Dist: httpcore (>=1.0.9,<2)
Requires-Dist: httpx (>=0.27.2,<0.28.0)
Requires-Dist: idna (>=3.15,<4)
Requires-Dist: numpy (>=1.26.4,<2) ; python_version < "3.13"
Requires-Dist: numpy (>=2.2,<3) ; python_version >= "3.13"
Requires-Dist: pandas (>=2.2.2,<3.0.0)
Requires-Dist: pillow (>=12.3.0,<13) ; python_version < "3.11"
Requires-Dist: pillow (>=13.0.0,<14) ; python_version >= "3.11"
Requires-Dist: python-dotenv (>=1.2.2,<2)
Requires-Dist: pyyaml (>=6.0.3,<7)
Requires-Dist: starlette (>=1.3.1,<2)
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
Requires-Dist: uvicorn[standard] (>=0.27.0,<1)
Project-URL: Repository, https://github.com/toshi-pono/aiotraq
Project-URL: Source Code, https://github.com/toshi-pono/aiotraq/tree/main/libs/message
Description-Content-Type: text/markdown

# AiotraQ-Message

streamlit 風の構文を用いてインタラクティブなメッセージ送信に対応するプラグインです。

[![PyPI - Version](https://img.shields.io/pypi/v/aiotraq-message?label=aiotraq-message)](https://pypi.org/project/aiotraq-message/)
[![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)

## Installation

```bash
pip install aiotraq-message
```

## Requirements

AiotraQ-Message は AiotraQ に依存しています

- [AiotraQ](https://github.com/toshi-pono/aiotraq/tree/main/libs/aiotraq)
- [AiotraQ-Bot](https://github.com/toshi-pono/aiotraq/tree/main/libs/bot)

![overview](../../docs/docs/overview.svg)

## Usage

```python
import os
import asyncio
from aiotraq_bot import TraqHttpBot
from aiotraq_message import TraqMessage

async def component(am: TraqMessage, payload: str):
    am.write("Hello, World!")
    am.write(payload)

    with am.spinner():
        # heavy task
        asyncio.sleep(3)

    am.write(":done: Done!")

bot = TraqHttpBot(verification_token=os.getenv("BOT_VERIFICATION_TOKEN"))
response = TraqMessageManager(bot, os.getenv("BOT_ACCESS_TOKEN"), "https://q.trap.jp/api/v3", "https://q.trap.jp")


@bot.event("MESSAGE_CREATED")
async def on_message_created(payload) -> None:
    channel_id = payload.message.channelId
    message = payload.message.plainText

    await response(component, channnel_id=channel_id, payload=message)

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

### Component

write, spinner, clear などのメソッドを使うことができます

- write: メッセージを送信します
- spinner: スピナーを表示します
- clear: 送信したメッセージを空にします
- clear_message: write で送信したメッセージ 1 つを削除します
- image: 画像を送信します
- pyplot: matplotlib のグラフを送信します
- dataframe: pandas の dataframe を表形式で表示します

詳細: [ドキュメント｜ Components](https://toshi-pono.github.io/aiotraq/docs/api/components/overview/)

## License

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

