@koishijs/plugin-server 实现了一个 Satori 协议 的服务器。这个插件将允许你:
- 通过 HTTP / WebSocket 访问当前 Koishi 实例中的机器人
- 配合 Satori 适配器,在另一个 Koishi 实例中完全控制当前实例中的机器人
场景 1:让 Koishi 暴露一套 API,以便我推送消息
安装 server 插件,然后直接 POST 请求 /v1/message.create
即可。
完整的文档请参考 Satori 协议。
场景 2:让适配器分布式地运行在不同的机器上,再通过一个中心 Koishi 实例统一管理
在多台机器上分别运行 Koishi。负责适配器的 Koishi 实例安装适配器插件和 server 插件;中心 Koishi 实例安装多个 adapter-satori 插件即可。
6 个赞
大佬,求问 server的path该怎么填写
是一个怎么样的格式呀
2 个赞
shigma
3
空着不写即可。
请记住原则:如无必要,勿动配置。凡是非必需的配置一律不要动,除非你知道你在做什么。
3 个赞
有使用教程吗。看nonebot的red适配器说推荐用satori,可以连接到koishi,但不知道怎么用
4 个赞
直接启用插件即可。之后你就可以连接到 Satori 服务了。
2 个赞
尝试搭建API服务,ctx.bots为空,导致提示403 login not found
headers = {
# 'Content-Type': 'application/json',
# 'Authorization': 'Bearer 1',
'Satori-Platform': 'sandbox:xxx',
'Satori-User-ID': 'Alice'
}
#
content = 'thpt xxx'
r = requests.post('http://localhost:5140/satori/v1/message.create', data={
'channel_id': 'API', 'content': content
}, headers=headers)
# r = requests.post('http://localhost:5140/satori/v1/channel.get', headers=headers, params={})
print(r.text)
print(r.status_code)
2 个赞