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
  • nekobox
  • Koishi (搭配 @koishijs/plugin-server, 其余内容请自行阅读 koishi 文档)

配置

修改 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

以对接 nekobox 为例

你可以通过 nekobox show 命令来获取当前的配置信息。

$ nekobox show xxxxxx
SignUrl:        xxxxxxxxxxxxx
协议类型:       linux
验证 token:     *************
服务器绑定地址: 127.0.0.1
服务器绑定端口: 7788
服务器部署路径: neko
默认日志等级:   INFO

此时

  • host服务器绑定地址 一致
  • port服务器绑定端口 一致
  • path服务器部署路径 一致
  • token验证 token 一致

示例

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.13.8.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_adapter_satori-0.13.8-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nonebot_adapter_satori-0.13.8.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.2 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for nonebot_adapter_satori-0.13.8.tar.gz
Algorithm Hash digest
SHA256 477f05c0887855f1c665c36286df3438be703e15f24af19b468b57dcbd3f231e
MD5 9b2d3bf45010d469318888a9dea2a92b
BLAKE2b-256 7867bed05ae5f428a50e44cbdc4d1f8bf1796d70e8dcdaa911eaf56a94d9fe3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nonebot_adapter_satori-0.13.8-py3-none-any.whl
Algorithm Hash digest
SHA256 20547f218943018fc5ec3c6511f8961bb1c10308f4a40f8989d082c1d0096691
MD5 617e4ddbec0ec9ac2211354ba4b51efd
BLAKE2b-256 a477f2a9eb5d943f4a0e89510104e76204ea48ca4e94cd4a0c93c57f1dfbf1c9

See more details on using hashes here.

Supported by

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