Skip to main content

Spoonbot

Spoonbotは、オーディオライブプラットフォーム「Spoon」が公開している、Bot機能の提供API「Spoon Developpers」を非常に簡単に利用できるようにするラッパーライブラリです。

主な特徴は以下の通りです。

  • 周辺処理不要: Oauth認可、トークン管理、エラーハンドリング、再接続などSpoon Developpersを利用するために本来必要な様々な周辺処理を実装せずに済みます。
  • 直感的: PythonでBot開発を行うときによく見られる直感的な書き方でSpoonのBotを開発できます。
  • 簡単: 少ない記述で実装可能。水平スケールしないのであれば、内臓のSQLite3ですぐに動作します。(MySQLも利用可)
  • 型安全: Spoon Developpersからの応答はPydanticによって検証され、エディタ補完の効くデータとして受け取ることができます。

Spoon Developpersの申請

本ライブラリの使用するためには、以下の申請が完了している必要があります。

https://developers.spooncast.net/docs/ja/getting-started/app-registration

注意

Spoon Developpers申請に利用したアカウントはそのままボットアカウントとして、連携先のDJのライブでチャット送信などを行います。(Botアカウントが発行されるわけではなく、自分のアカウントがBotのように振る舞うようになる。)
これは、本ライブラリの仕様ではなくSpoon Developpersの仕様です。詳細はSpoon Developpersにお問い合わせください。

インストール

pip install spoonbot

uvを利用するのであれば、

uv add spoonbot

Example

以下の内容でmain.pyを作成します。

from spoonbot import (
    ChatEvent,
    SpoonBot,
    SpoonPermission,
)

spoonbot = SpoonBot(
    permissions=set(SpoonPermission)
    # 権限を個別に指定する場合 ↓
    # ここで指定しなかったとしても、チャットの送受信と連携ユーザーの情報取得権限は本ライブラリの最低要件として自動指定されます。
    # permissions={SpoonPermission.EVENTS_LIKE, SpoonPermission.DJ_FOLLOW}
)


@spoonbot.chat_event
async def hello(chat_event: ChatEvent):
    if chat_event.chat_body.message == "Hello":
        await spoonbot.send_chat(
            f"Hello world {chat_event.chat_body.user.nickname}!!",
            chat_event.authorization,
        )

spoonbot.start()
他にも、様々なイベントを受け取れます
@spoonbot.connect_event
async def first_message(connect_event: ConnectEvent):
    if not connect_event.reconnect:
        await spoonbot.send_chat(
            "I’m here!",
            connect_event.authorization,
        )

@spoonbot.like_event
async def like(like_event: LikeEvent):
    await spoonbot.send_chat(
        f"Thankyou Heart!! {like_event.like_body.user.nickname}!!",
        like_event.authorization,
    )


@spoonbot.join_event
async def join(join_event: JoinEvent):
    await spoonbot.send_chat(
        f"Welcome {join_event.presence_body.user.nickname}!!",
        join_event.authorization,
    )


@spoonbot.gift_event
async def gift(gift_event: GiftEvent):
    await spoonbot.send_chat(
        f"Thankyou gift! {gift_event.donation_body.user.nickname}!!",
        gift_event.authorization,
    )


@spoonbot.follow_event
async def follow(follow_event: FollowEvent):
    await spoonbot.send_chat(
        f"Thankyou follow! {follow_event.follow_body.user.nickname}!!",
        follow_event.authorization,
    )


@spoonbot.end_event
async def end(end_event: EndEvent):
    print(f"bye {end_event.authorization.id}")

必要な環境変数

必須の物は必ず指定する必要があります。ただし、環境変数キーまたはSpoonBot初期荷時引数のどちらかで指定すればよいです。

環境変数キー SpoonBot初期化時引数 説明 必須
SPOON_CLIENT_ID spoon_client_id Spoon Developpersのコンソールページで発行したClient id。 ✅
SPOON_CLIENT_SECRET spoon_client_secret sk_live_ から始まる、Spoon Developpersのコンソールページで発行したClient Secret。この値は漏洩するとbotを乗っ取られるので、適切に管理します。 ✅
SPOON_OAUTH_REDIRECT_URL oauth_redirect_url Spoon Developpersのコンソールページで指定したコールバックURL。コンソールで指定したものと1字1句同じである必要があります。本ライブラリを用いて構築した場合、pathは自動的に「/oauth/callback」となります。 ✅
SPOON_SECRET_KEY secret_key ランダムな32文字以上のシークレットキーを生成して指定します。これはSpoon Developpersで発行されるものではありません。sessionのキーなどに利用するので、水平スケールする場合は全てのpodで同一のIDにする必要があります。
生成方法の一例: openssl rand -base64 22
✅
SPOON_BOT_COUNTRY country どの国のSpoonで提供するかを指定します。Spoon Developpersでbotを発行したドメインの国と合わせる必要があります。 JP | KR ✅
SPOON_BOT_PORT port spoonbotを立ち上げるポートを指定します。デフォルトは8080です。
SPOON_BOT_NAME bot_name Oauth連携ページや、Bot招待ページにて表示される名前を指定します。デフォルトは「Spoon Bot」です。
bot_operation_page botに関する追加のページを実装し提供する場合、そのパスもしくはURLを指定してください。Bot招待ページに引数で指定したページへ遷移するボタンが出現します。 例えば、web上で入力した値を保存しておき、毎回ライブの最初に送信するといったbotを実装するとき、該当のwebページのパスまたはurlを指定するとよいでしょう。

実行

以下のコマンドで実行し、web上に公開します。必要に応じて上段にNginxなどを設ければよいと思いますが、小規模であればその必要もないと思います。

python main.py

または

uv run main.py

連携

Botを連携するには、まず以下のURLを案内します。
https://{your domain}/spoonbot/connect

spoonbot-test aakun-da f5 si_spoonbot_connect(iPhone 16)

「ボットを連携する」をクリックし、spoonのページで認証認可を完了すると、以下のページへ遷移します

spoonbot-test aakun-da f5 si_spoonbot_success(iPhone 16)

「ボット招待ページへ」を押した後、先ほど連携したアカウントで、Spoonライブ配信を開始してください。
ライブ配信を開始したら、「今すぐBotを招待する」を押してください。

spoonbot-test aakun-da f5 si_spoonbot_invite(iPhone 16)

Spoon Developpersを申請したアカウントがBotとして配信に入室してきたら、連携成功です。

スクリーンショット 2026-11-10 210610

最後に

  • このラッパーライブラリは現在ベータ版です
  • 本ライブラリは㈱Spoonlabs Japan が提供するオーディオライブプラットフォーム「Spoon」内で利用できるAPIである「Spoon Developpers」を便利に利用できるようにしたものですが、本ライブラリおよび開発者は㈱Spoonlabs Japan とは一切関係ありません。

Metadata

Release files for spoonbot 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spoonbot 0.1.12
File Size Uploaded Provenance Actions
spoonbot-0.1.12.tar.gz 33.3 kB Without provenance Details for spoonbot-0.1.12.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spoonbot 0.1.12
File Interpreter ABI Platform Actions
spoonbot-0.1.12-py3-none-any.whl Python 3 none any Details for spoonbot-0.1.12-py3-none-any.whl

Total release size: 88.5 kB

Release files / spoonbot-0.1.12.tar.gz

Download URL spoonbot-0.1.12.tar.gz
Size 33.3 kB
Tags Source
SHA-256 checksum
How to use checksums
337ef7bb93eda3b568ad412bd037b5a728d1da71ac4bc4937b2f92053dc23afd
BLAKE2b-256 checksum
How to use checksums
cd49646201f4c694132e53754f282fe82db3078990c69454c260572008171d42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spoonbot-0.1.12-py3-none-any.whl

Download URL spoonbot-0.1.12-py3-none-any.whl
Size 55.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
839b9f5afa4f916e289827c3975b3d8404103d5c7a72222e4b9a998e9cd4fce0
BLAKE2b-256 checksum
How to use checksums
688e74888c05e232a51fcdb1c5bda5749f93123ad2a03efd8e374a6753fb71c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for spoonbot 0.1.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page