aiotraq Plugin that supports interactive message sending using Streamlit-style syntax for traQ
Project description
AiotraQ-Message
streamlit 風の構文を用いてインタラクティブなメッセージ送信に対応するプラグインです。
Installation
pip install aiotraq-message
Requirements
AiotraQ-Message は AiotraQ に依存しています
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 を表形式で表示します
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.4.tar.gz
(7.9 kB
view details)
Built Distribution
File details
Details for the file aiotraq_message-0.2.4.tar.gz
.
File metadata
- Download URL: aiotraq_message-0.2.4.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d132cf5729050124a0a65f1aaf8278ba53616ac12d92e29957713bb5e87b9df0 |
|
MD5 | 5c4fb4498b0cc55f4d6308ede4507a2e |
|
BLAKE2b-256 | 0aad71beb9f30a6951d3816bb2a519a5dae64ec29839f144e467544b1f2f4327 |
File details
Details for the file aiotraq_message-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: aiotraq_message-0.2.4-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ca36efa003a153dc215342f3f2478267a7664605dba7e67bc7849a7be34e80d |
|
MD5 | 1f1f3d0cc520d2918ac591e6076595fc |
|
BLAKE2b-256 | 836291c909e7007a644f64ce79ae63752f60b81166ecdd409337aebd4824c5ca |