Skip to main content

aiotraq Plugin that supports interactive message sending using Streamlit-style syntax for traQ

Project description

AiotraQ-Message

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

PyPI - Version GitHub license CI

Installation

pip install aiotraq-message

Requirements

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

overview

Usage

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

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_message-0.2.3.tar.gz (7.9 kB view hashes)

Uploaded Source

Built Distribution

aiotraq_message-0.2.3-py3-none-any.whl (8.7 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