Skip to main content

Async ready traQ Bot library

Project description

aiotraq-bot

Async ready traQ Bot library written in Python.

Installation

TODO

Usage

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


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.0.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

aiotraq_bot-0.1.0-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page