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
  • LLBot
  • 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",
    "timeout": 30
  }
]
'

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

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

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

timeout 为连接超时时间。

以对接 LLBot 为例

参考 LLBot 的 satori 接入文档

以对接 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-1.3.0.tar.gz (30.7 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-1.3.0-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nonebot_adapter_satori-1.3.0.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.6 CPython/3.12.3 Linux/6.14.0-1017-azure

File hashes

Hashes for nonebot_adapter_satori-1.3.0.tar.gz
Algorithm Hash digest
SHA256 6d94416c38adaedeed1db75af12871720ddf8efd99d1bd568d1911c41c1132a6
MD5 536810bb8ecb67975ee6f024361d147b
BLAKE2b-256 6353eb7b3ba0d0b5d9e2385b874f8f993df6cd77bb008621e751e196085a6e26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nonebot_adapter_satori-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6dbeac22df91140632e9b99f80924a049f924f5af976418147885b13728420a9
MD5 33dce7fc10eb60a34d97ba48d411a032
BLAKE2b-256 49d7f2451b78f90317d456cea3303a38628401239d2637e72e628632c7472f3c

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