Satori Protocol SDK for python
Project description
satori-python
基于 Satori 协议的 Python 开发工具包
协议介绍
协议端
目前提供了 satori 协议实现的有:
使用该 SDK 的框架
安装
安装完整体:
pip install satori-python
只安装基础部分:
pip install satori-python-core
只安装客户端部分:
pip install satori-python-client
只安装服务端部分:
pip install satori-python-server
官方适配器
| 适配器 | 安装 | 路径 |
|---|---|---|
| Satori | pip install satori-python-adapter-satori |
satori.adapters.satori |
| OneBot V11 | pip install satori-python-adapter-onebot11 |
satori.adapters.onebot11.forward, satori.adapters.onebot11.reverse |
| Console | pip install satori-python-adapter-console |
satori.adapters.console |
社区适配器
| 适配器 | 安装 | 路径 |
|---|---|---|
| nekobox(Lagrange) | pip install nekobox |
nekobox.main |
使用
客户端:
from satori import EventType
from satori.event import MessageEvent
from satori.client import Account, App, WebsocketsInfo
app = App(WebsocketsInfo(port=5140))
@app.register_on(EventType.MESSAGE_CREATED)
async def on_message(account: Account, event: MessageEvent):
if event.user.id == "xxxxxxxxxxx":
await account.send(event, "Hello, World!")
app.run()
服务端:
from satori import Api
from satori.server import Server
server = Server(port=5140)
@server.route(Api.MESSAGE_CREATE)
async def on_message_create(*args, **kwargs):
return [{"id": "1234", "content": "example"}]
server.run()
文档
请阅读 仓库文档
示例
- 客户端:client.py
- 服务端:server.py
- 服务端(使用适配器):server_with_adapter.py
- 客户端(webhook):client_webhook
- 服务端(webhook):server_webhook
- 适配器:adapter.py
架构
graph LR
subgraph Server
server -- run --> asgi
server -- register --> router -- mount --> asgi
server -- apply --> provider -- mount --> asgi
provider -- event,logins --> server
end
subgraph Client
config -- apply --> app -- run --> network
app -- register --> listener
network -- account,event --> listener
listener -- handle --> account -- session --> api
end
api -- request --> asgi -- response --> api
server -- raw-event --> asgi -- websocket/webhook --> network
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
satori_python-0.16.7.tar.gz
(40.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file satori_python-0.16.7.tar.gz.
File metadata
- Download URL: satori_python-0.16.7.tar.gz
- Upload date:
- Size: 40.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.25.5 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cf394166f6bbecf27863403dc48245f1de457c911eff5656fae497b3a54f081
|
|
| MD5 |
2762528894d6930ac96128feec1bd825
|
|
| BLAKE2b-256 |
07a4818d74f1dfd506d127e22ab2a8252e321c3350c9c3d3079c9d8de20499b1
|
File details
Details for the file satori_python-0.16.7-py3-none-any.whl.
File metadata
- Download URL: satori_python-0.16.7-py3-none-any.whl
- Upload date:
- Size: 47.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.25.5 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f31887bc8ac1be8faac3bc9f56464638b363c1f0022fe73123c15a7f752f7316
|
|
| MD5 |
73f4c1dbd13568eb12e41b38b69aa780
|
|
| BLAKE2b-256 |
96960abb579a87fb97321ddb4217a6799de47bc368340c9039af97f505227b62
|