aiotraq-bot


Nameaiotraq-bot JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/toshi-pono/aiotraq
SummaryAsync ready traQ Bot library
upload_time2024-06-02 10:10:25
maintainerNone
docs_urlNone
authortoshi00
requires_python<4.0,>=3.10
licenseMIT
keywords traq bot async aiotraq
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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) 等を利用してください。

```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)
```

## 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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/toshi-pono/aiotraq",
    "name": "aiotraq-bot",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "traQ, bot, async, aiotraq",
    "author": "toshi00",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d4/d1/dbdc5840ea6e602379a0d849becc0f690cb6ba56bcd7ff0f471265bdd17a/aiotraq_bot-0.1.2.tar.gz",
    "platform": null,
    "description": "# aiotraq-bot\n\nAsync ready traQ Bot library written in Python.\n\n[![PyPI - Version](https://img.shields.io/pypi/v/aiotraq-bot)](https://pypi.org/project/aiotraq-bot/)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toshi-pono/aiotraq/blob/main/LICENSE)\n[![CI](https://github.com/toshi-pono/aiotraq/actions/workflows/ci.yml/badge.svg)](https://github.com/toshi-pono/aiotraq/actions/workflows/ci.yml)\n\n## Requirements\n\naiotraq-bot \u306f\u4ee5\u4e0b\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002\n\n- [FastAPI](https://fastapi.tiangolo.com/): \u30b5\u30fc\u30d0\u30fc\u306e\u5b9f\u88c5\n- [Uvicorn](https://www.uvicorn.org/): \u30b5\u30fc\u30d0\u30fc\u306e\u5b9f\u884c\n- [Pydantic](https://docs.pydantic.dev/latest/): \u30c7\u30fc\u30bf\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\n\n## Installation\n\n```bash\npip install aiotraq-bot\n```\n\n## Usage\n\n`TraqHttpBot` \u3092\u4f7f\u3063\u3066 http bot \u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\n\n`traQ->BOT\u30b5\u30fc\u30d0\u30fc`\u3078\u306e\u30a4\u30d9\u30f3\u30c8\u53d7\u3051\u53d6\u308a\u90e8\u5206\u3092\u88dc\u52a9\u3057\u307e\u3059\u3002\n`BOT\u30b5\u30fc\u30d0\u30fc->traQ`\u3078\u306e\u30a4\u30d9\u30f3\u30c8\u9001\u4fe1\u306f [aiotraq](https://github.com/toshi-pono/aiotraq/tree/main/libs/aiotraq) \u7b49\u3092\u5229\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n```python\nimport os\nfrom aiotraq_bot import TraqHttpBot\n\nbot = TraqHttpBot(verification_token=os.getenv(\"BOT_VERIFICATION_TOKEN\"))\n\n@bot.event()\nasync def on_message(payload: MessageCreatedPayload):\n    print(payload)\n\nif __name__ == \"__main__\":\n  bot.run()\n```\n\n### Event handler \u306e\u767b\u9332\n\n\u30a4\u30d9\u30f3\u30c8\u306e\u767b\u9332\u306f `@bot.event()` \u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\nevent \u306e\u5f15\u6570\u3068\u3057\u3066\u5bfe\u8c61\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u6307\u5b9a\u3059\u308b\u304b\u3001\u95a2\u6570\u306e\u578b\u30d2\u30f3\u30c8\u3092\u4f7f\u3063\u3066\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\n\n`MESSAGE_CREATED` \u30a4\u30d9\u30f3\u30c8\u3092\u578b\u30d2\u30f3\u30c8\u3092\u4f7f\u3063\u3066\u6307\u5b9a\u3059\u308b\u5834\u5408\n\n```python\n@bot.event()\nasync def on_message(payload: MessageCreatedPayload):\n    print(payload)\n```\n\n`MESSAGE_CREATED`\u30a4\u30d9\u30f3\u30c8\u3092\u5f15\u6570\u3092\u7528\u3044\u3066\u6307\u5b9a\u3059\u308b\u5834\u5408\n\n```python\n@bot.event(\"MESSAGE_CREATED\")\nasync def on_message(payload):\n    print(payload)\n```\n\n## Acknowledgements\n\nThis project is inspired by [python-traq-bot](https://github.com/eyemono-moe/python-traq-bot).\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Async ready traQ Bot library",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/toshi-pono/aiotraq",
        "Repository": "https://github.com/toshi-pono/aiotraq",
        "Source Code": "https://github.com/toshi-pono/aiotraq/tree/main/libs/bot"
    },
    "split_keywords": [
        "traq",
        " bot",
        " async",
        " aiotraq"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af34fd9ac49f5310f981fee0431bd62c09fcbd0149c910d5243b5fb7f67df515",
                "md5": "37c595abc6e9f1f2aff29fde54691c33",
                "sha256": "601cbcf0c38ea468e9ff4591b6357aa35e8bda6ffd2fbeb973e5a446baa387bb"
            },
            "downloads": -1,
            "filename": "aiotraq_bot-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "37c595abc6e9f1f2aff29fde54691c33",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 8640,
            "upload_time": "2024-06-02T10:10:23",
            "upload_time_iso_8601": "2024-06-02T10:10:23.729694Z",
            "url": "https://files.pythonhosted.org/packages/af/34/fd9ac49f5310f981fee0431bd62c09fcbd0149c910d5243b5fb7f67df515/aiotraq_bot-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d4d1dbdc5840ea6e602379a0d849becc0f690cb6ba56bcd7ff0f471265bdd17a",
                "md5": "29b2215b699a9c5f30337ef8afdadf98",
                "sha256": "8da3a227cbb1c4ccaa43325edf7ebf7336f801c8fa7e427e5fda90e34a693113"
            },
            "downloads": -1,
            "filename": "aiotraq_bot-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "29b2215b699a9c5f30337ef8afdadf98",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 7479,
            "upload_time": "2024-06-02T10:10:25",
            "upload_time_iso_8601": "2024-06-02T10:10:25.155046Z",
            "url": "https://files.pythonhosted.org/packages/d4/d1/dbdc5840ea6e602379a0d849becc0f690cb6ba56bcd7ff0f471265bdd17a/aiotraq_bot-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-02 10:10:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "toshi-pono",
    "github_project": "aiotraq",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aiotraq-bot"
}
        
Elapsed time: 0.24927s