Async ready traQ Bot library
Project description
aiotraq-bot
Async ready traQ Bot library written in Python.
Requirements
aiotraq-bot は以下のライブラリを使用しています。
Installation
pip install aiotraq-bot
Usage
TraqHttpBot
を使って http bot を作成することができます。
traQ->BOTサーバー
へのイベント受け取り部分を補助します。
BOTサーバー->traQ
へのイベント送信は aiotraq 等を利用してください。
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
イベントを型ヒントを使って指定する場合
@bot.event()
async def on_message(payload: MessageCreatedPayload):
print(payload)
MESSAGE_CREATED
イベントを引数を用いて指定する場合
@bot.event("MESSAGE_CREATED")
async def on_message(payload):
print(payload)
Acknowledgements
This project is inspired by python-traq-bot.
License
This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiotraq_bot-0.1.2.tar.gz
(7.5 kB
view hashes)
Built Distribution
Close
Hashes for aiotraq_bot-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 601cbcf0c38ea468e9ff4591b6357aa35e8bda6ffd2fbeb973e5a446baa387bb |
|
MD5 | 37c595abc6e9f1f2aff29fde54691c33 |
|
BLAKE2b-256 | af34fd9ac49f5310f981fee0431bd62c09fcbd0149c910d5243b5fb7f67df515 |