Skip to main content

NoneBot-Adapter-Satori

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

协议介绍

Satori Protocol

协议端

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

  • Chronocat
  • LLBot
  • nekobox
  • Koishi (搭配 @koishijs/plugin-server, 其余内容请自行阅读 koishi 文档)

配置

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

Driver

参考 driver 配置项,添加 HTTPClient 和 WebSocketClient 支持。

如:

DRIVER=~httpx+~websockets

或

DRIVER=~aiohttp

SATORI_CLIENTS

配置连接配置,如:

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

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

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

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

timeout 为连接超时时间。

以对接 LLBot 为例

参考 LLBot 的 satori 接入文档

以对接 Chronocat 为例

你需要从 Chronocat 的配置文件 ~/.chronocat/config/chronocat.yml 中获取 port、token、host。

在单账号下,

  • 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!"))

Metadata

Release files for nonebot-adapter-satori 1.3.0

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

Source distribution (sdist)

Source distribution for nonebot-adapter-satori 1.3.0
File Size Uploaded
nonebot_adapter_satori-1.3.0.tar.gz 30.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-adapter-satori 1.3.0
File Interpreter ABI Platform
nonebot_adapter_satori-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 60.0 kB

Release files / nonebot_adapter_satori-1.3.0.tar.gz

Download URL nonebot_adapter_satori-1.3.0.tar.gz
Size 30.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6d94416c38adaedeed1db75af12871720ddf8efd99d1bd568d1911c41c1132a6
BLAKE2b-256 checksum
How to use checksums
6353eb7b3ba0d0b5d9e2385b874f8f993df6cd77bb008621e751e196085a6e26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.6 CPython/3.12.3 Linux/6.14.0-1017-azure

Release files / nonebot_adapter_satori-1.3.0-py3-none-any.whl

Download URL nonebot_adapter_satori-1.3.0-py3-none-any.whl
Size 29.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6dbeac22df91140632e9b99f80924a049f924f5af976418147885b13728420a9
BLAKE2b-256 checksum
How to use checksums
49d7f2451b78f90317d456cea3303a38628401239d2637e72e628632c7472f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.6 CPython/3.12.3 Linux/6.14.0-1017-azure

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

0.13.8

2 release files

0.13.7

2 release files

0.13.6

2 release files

0.13.5

2 release files

0.13.3

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.6

2 release files

0.12.3

2 release files

0.12.2

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.4

2 release files

0.11.3

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.5

2 release files

0.10.3

2 release files

0.10.2

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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