协议介绍
协议端
目前提供了 satori 协议实现的有:
配置
修改 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只能对应一个porttoken与配置文件下下的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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot_adapter_satori-1.3.0.tar.gz | 30.7 kB | Without provenance | Details for nonebot_adapter_satori-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_adapter_satori-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for nonebot_adapter_satori-1.3.0-py3-none-any.whl |
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
|
Security for nonebot-adapter-satori 1.3.0
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.