Skip to main content

Satori Protocol Adapter for Nonebot2

Project description

NoneBot-Adapter-Satori

✨ NoneBot2 Satori Protocol适配器 / Satori Protocol Adapter for NoneBot2 ✨

协议介绍

Satori Protocol

协议端

目前提供了 satori 协议实现的有:

  • Chronocat
  • Koishi (搭配 @koishijs/plugin-server

配置

修改 NoneBot 配置文件 .env 或者 .env.*

Driver

参考 driver 配置项,添加 HTTPClientWebSocketClient 支持。

如:

DRIVER=~httpx+~websockets

DRIVER=~aiohttp

SATORI_CLIENTS

配置连接配置,如:

SATORI_CLIENTS='
[
  {
    "host": "localhost",
    "port": "5500",
    "path": "",
    "token": "xxx"
  }
]
'

hostport 为 Satori 服务端的监听地址与端口,

path 为 Satori 服务端自定义的监听路径,如 "/satori",默认为 ""

token 由 Satori 服务端决定是否需要 (例如,对接 Chronocat 就需要此项)。

以对接 Chronocat 为例

你需要从 Chronocat 的配置文件 ~/.chronocat/config/chronocat.yml 中获取 porttokenhost

在单账号下,

  • host 与配置文件下的 servers[X].listen 一致
  • port 与配置文件下的 servers[X].port 一致
  • token 与配置文件下的 servers[X].token 一致
# ~/.chronocat/config/chronocat.yml
servers:
  - type: satori
    # Chronocat 已经自动生成了随机 token。要妥善保存哦!
    # 客户端使用服务时需要提供这个 token!
    token: DEFINE_CHRONO_TOKEN  # token
    # Chronocat 开启 satori 服务的端口,默认为 5500。
    port: 5500  # port
    # 服务器监听的地址。 如果你不知道这是什么,那么不填此项即可!
    listen: localhost  # host

而多账号下,

  • host 与配置文件下下的 overrides[QQ].servers[X].listen 一致
  • port 与配置文件下下的 overrides[QQ].servers[X].port 一致,并且一个 QQ 只能对应一个 port
  • token 与配置文件下下的 overrides[QQ].servers[X].token 一致
# ~/.chronocat/config/chronocat.yml
overrides:
  1234567890:
    servers:
      - type: satori
        # Chronocat 已经自动生成了随机 token。要妥善保存哦!
        # 客户端使用服务时需要提供这个 token!
        token: DEFINE_CHRONO_TOKEN  # token
        # Chronocat 开启 satori 服务的端口,默认为 5500。
        port: 5501  # port
        # 服务器监听的地址。 如果你不知道这是什么,那么不填此项即可!
        listen: localhost

配置文件详细内容请参考 Chronocat/config

示例

from nonebot import on_command
from nonebot.adapters.satori import Bot
from nonebot.adapters.satori.event import MessageEvent
from nonebot.adapters.satori.message import MessageSegment


matcher = on_command("test")

@matcher.handle()
async def handle_receive(bot: Bot, event: MessageEvent):
    if event.is_private:
        await bot.send(event, MessageSegment.text("Hello, world!"))

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

nonebot_adapter_satori-0.12.6.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

nonebot_adapter_satori-0.12.6-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_adapter_satori-0.12.6.tar.gz.

File metadata

  • Download URL: nonebot_adapter_satori-0.12.6.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.18.2 CPython/3.10.12 Linux/6.8.0-1014-azure

File hashes

Hashes for nonebot_adapter_satori-0.12.6.tar.gz
Algorithm Hash digest
SHA256 afce9c5ded45ca302b8c42c5ad13c675ca956d00dc47dc99e0bc5acf7e62d093
MD5 6ce671b8af45d5af46f28be770e6dc6c
BLAKE2b-256 dc211a86c70fd8622a658a6a92c8ba3eeb04571c843b7de192d02507994d4046

See more details on using hashes here.

File details

Details for the file nonebot_adapter_satori-0.12.6-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_adapter_satori-0.12.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b15d9a8d90e0ceb9a133d6443b505c9e3e1df65a5ae77719022a1c20b1d96f83
MD5 b8b843910664848812008a821cf2ffc9
BLAKE2b-256 8df83ac0075f00711e0a8a655feb4deb05de35aa16f8e64a7d5e6acc42c637bb

See more details on using hashes here.

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