satori-python-adapter-onebot11 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ includes = ["src/satori/adapters/onebot11"]
2
+ raw-dependencies = ["satori-python-server >= 0.16.4"]
3
+
4
+ [project]
5
+ name = "satori-python-adapter-onebot11"
6
+ version = "0.1.0"
7
+ authors = [
8
+ {name = "RF-Tar-Railt", email = "rf_tar_railt@qq.com"}
9
+ ]
10
+ dependencies = []
11
+ description = "Satori Protocol SDK for python, adapter for OneBot 11"
12
+ license = {text = "MIT"}
13
+ readme = "README.md"
14
+ requires-python = ">=3.9"
15
+ classifiers = [
16
+ "Typing :: Typed",
17
+ "Development Status :: 4 - Beta",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Operating System :: OS Independent",
25
+ ]
26
+
27
+ [project.urls]
28
+ homepage = "https://github.com/RF-Tar-Railt/satori-python"
29
+ repository = "https://github.com/RF-Tar-Railt/satori-python"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 RF-Tar-Railt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.1
2
+ Name: satori-python-adapter-onebot11
3
+ Version: 0.1.0
4
+ Summary: Satori Protocol SDK for python, adapter for OneBot 11
5
+ Home-page: https://github.com/RF-Tar-Railt/satori-python
6
+ Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
7
+ License: MIT
8
+ Classifier: Typing :: Typed
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Operating System :: OS Independent
17
+ Project-URL: Homepage, https://github.com/RF-Tar-Railt/satori-python
18
+ Project-URL: Repository, https://github.com/RF-Tar-Railt/satori-python
19
+ Requires-Python: >=3.9
20
+ Requires-Dist: satori-python-server>=0.16.4
21
+ Description-Content-Type: text/markdown
22
+
23
+ # satori-python
24
+
25
+ ![latest release](https://img.shields.io/github/release/RF-Tar-Railt/satori-python)
26
+ [![Licence](https://img.shields.io/github/license/RF-Tar-Railt/satori-python)](https://github.com/RF-Tar-Railt/satori-python/blob/main/LICENSE)
27
+ [![PyPI](https://img.shields.io/pypi/v/satori-python)](https://pypi.org/project/satori-python)
28
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/satori-python)](https://www.python.org/)
29
+
30
+ 基于 [Satori](https://satori.js.org/zh-CN/) 协议的 Python 开发工具包
31
+
32
+ ## 协议介绍
33
+
34
+ [Satori Protocol](https://satori.js.org/zh-CN/)
35
+
36
+ ### 协议端
37
+
38
+ 目前提供了 `satori` 协议实现的有:
39
+
40
+ - [Chronocat](https://chronocat.vercel.app)
41
+ - [nekobox](https://github.com/wyapx/nekobox)
42
+ - Koishi (搭配 `@koishijs/plugin-server`)
43
+
44
+ ### 使用该 SDK 的框架
45
+
46
+ - [`Entari`](https://github.com/ArcletProject/Entari)
47
+
48
+ ## 安装
49
+
50
+ 安装完整体:
51
+ ```shell
52
+ pip install satori-python
53
+ ```
54
+
55
+ 只安装基础部分:
56
+ ```shell
57
+ pip install satori-python-core
58
+ ```
59
+
60
+ 只安装客户端部分:
61
+ ```shell
62
+ pip install satori-python-client
63
+ ```
64
+
65
+ 只安装服务端部分:
66
+ ```shell
67
+ pip install satori-python-server
68
+ ```
69
+
70
+ ### 官方适配器
71
+
72
+ | 适配器 | 安装 |
73
+ |------------|----------------------------------------------|
74
+ | Satori | `pip install satori-python-adapter-satori` |
75
+ | OneBot V11 | `pip install satori-python-adapter-onebot11` |
76
+
77
+ ## 使用
78
+
79
+ 客户端:
80
+
81
+ ```python
82
+ from satori import EventType
83
+ from satori.event import MessageEvent
84
+ from satori.client import Account, App, WebsocketsInfo
85
+
86
+ app = App(WebsocketsInfo(port=5140))
87
+
88
+ @app.register_on(EventType.MESSAGE_CREATED)
89
+ async def on_message(account: Account, event: MessageEvent):
90
+ if event.user.id == "xxxxxxxxxxx":
91
+ await account.send(event, "Hello, World!")
92
+
93
+ app.run()
94
+ ```
95
+
96
+ 服务端:
97
+
98
+ ```python
99
+ from satori import Api
100
+ from satori.server import Server
101
+
102
+ server = Server(port=5140)
103
+
104
+ @server.route(Api.MESSAGE_CREATE)
105
+ async def on_message_create(*args, **kwargs):
106
+ return [{"id": "1234", "content": "example"}]
107
+
108
+ server.run()
109
+ ```
110
+
111
+ ## 文档
112
+
113
+ 请阅读 [仓库文档](./docs.md)
114
+
115
+ ## 示例
116
+
117
+ - 客户端:[client.py](./example/client.py)
118
+ - 服务端:[server.py](./example/server.py)
119
+ - 服务端(使用适配器):[server_with_adapter.py](./example/server_with_adapter.py)
120
+ - 客户端(webhook):[client_webhook](./example/client_webhook.py)
121
+ - 服务端(webhook):[server_webhook](./example/server_webhook.py)
122
+ - 适配器:[adapter.py](./example/adapter.py)
123
+
124
+ ## 架构
125
+
126
+ ```mermaid
127
+ graph LR
128
+ subgraph Server
129
+ server -- run --> asgi
130
+ server -- register --> router -- mount --> asgi
131
+ server -- apply --> provider -- mount --> asgi
132
+ provider -- event,logins --> server
133
+ end
134
+ subgraph Client
135
+ config -- apply --> app -- run --> network
136
+ app -- register --> listener
137
+ network -- account,event --> listener
138
+ listener -- handle --> account -- session --> api
139
+ end
140
+
141
+ api -- request --> asgi -- response --> api
142
+ server -- raw-event --> asgi -- websocket/webhook --> network
143
+ ```
@@ -0,0 +1,121 @@
1
+ # satori-python
2
+
3
+ ![latest release](https://img.shields.io/github/release/RF-Tar-Railt/satori-python)
4
+ [![Licence](https://img.shields.io/github/license/RF-Tar-Railt/satori-python)](https://github.com/RF-Tar-Railt/satori-python/blob/main/LICENSE)
5
+ [![PyPI](https://img.shields.io/pypi/v/satori-python)](https://pypi.org/project/satori-python)
6
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/satori-python)](https://www.python.org/)
7
+
8
+ 基于 [Satori](https://satori.js.org/zh-CN/) 协议的 Python 开发工具包
9
+
10
+ ## 协议介绍
11
+
12
+ [Satori Protocol](https://satori.js.org/zh-CN/)
13
+
14
+ ### 协议端
15
+
16
+ 目前提供了 `satori` 协议实现的有:
17
+
18
+ - [Chronocat](https://chronocat.vercel.app)
19
+ - [nekobox](https://github.com/wyapx/nekobox)
20
+ - Koishi (搭配 `@koishijs/plugin-server`)
21
+
22
+ ### 使用该 SDK 的框架
23
+
24
+ - [`Entari`](https://github.com/ArcletProject/Entari)
25
+
26
+ ## 安装
27
+
28
+ 安装完整体:
29
+ ```shell
30
+ pip install satori-python
31
+ ```
32
+
33
+ 只安装基础部分:
34
+ ```shell
35
+ pip install satori-python-core
36
+ ```
37
+
38
+ 只安装客户端部分:
39
+ ```shell
40
+ pip install satori-python-client
41
+ ```
42
+
43
+ 只安装服务端部分:
44
+ ```shell
45
+ pip install satori-python-server
46
+ ```
47
+
48
+ ### 官方适配器
49
+
50
+ | 适配器 | 安装 |
51
+ |------------|----------------------------------------------|
52
+ | Satori | `pip install satori-python-adapter-satori` |
53
+ | OneBot V11 | `pip install satori-python-adapter-onebot11` |
54
+
55
+ ## 使用
56
+
57
+ 客户端:
58
+
59
+ ```python
60
+ from satori import EventType
61
+ from satori.event import MessageEvent
62
+ from satori.client import Account, App, WebsocketsInfo
63
+
64
+ app = App(WebsocketsInfo(port=5140))
65
+
66
+ @app.register_on(EventType.MESSAGE_CREATED)
67
+ async def on_message(account: Account, event: MessageEvent):
68
+ if event.user.id == "xxxxxxxxxxx":
69
+ await account.send(event, "Hello, World!")
70
+
71
+ app.run()
72
+ ```
73
+
74
+ 服务端:
75
+
76
+ ```python
77
+ from satori import Api
78
+ from satori.server import Server
79
+
80
+ server = Server(port=5140)
81
+
82
+ @server.route(Api.MESSAGE_CREATE)
83
+ async def on_message_create(*args, **kwargs):
84
+ return [{"id": "1234", "content": "example"}]
85
+
86
+ server.run()
87
+ ```
88
+
89
+ ## 文档
90
+
91
+ 请阅读 [仓库文档](./docs.md)
92
+
93
+ ## 示例
94
+
95
+ - 客户端:[client.py](./example/client.py)
96
+ - 服务端:[server.py](./example/server.py)
97
+ - 服务端(使用适配器):[server_with_adapter.py](./example/server_with_adapter.py)
98
+ - 客户端(webhook):[client_webhook](./example/client_webhook.py)
99
+ - 服务端(webhook):[server_webhook](./example/server_webhook.py)
100
+ - 适配器:[adapter.py](./example/adapter.py)
101
+
102
+ ## 架构
103
+
104
+ ```mermaid
105
+ graph LR
106
+ subgraph Server
107
+ server -- run --> asgi
108
+ server -- register --> router -- mount --> asgi
109
+ server -- apply --> provider -- mount --> asgi
110
+ provider -- event,logins --> server
111
+ end
112
+ subgraph Client
113
+ config -- apply --> app -- run --> network
114
+ app -- register --> listener
115
+ network -- account,event --> listener
116
+ listener -- handle --> account -- session --> api
117
+ end
118
+
119
+ api -- request --> asgi -- response --> api
120
+ server -- raw-event --> asgi -- websocket/webhook --> network
121
+ ```
@@ -0,0 +1,113 @@
1
+ [project]
2
+ name = "satori-python-adapter-onebot11"
3
+ version = "0.1.0"
4
+ authors = [
5
+ { name = "RF-Tar-Railt", email = "rf_tar_railt@qq.com" },
6
+ ]
7
+ dependencies = [
8
+ "satori-python-server >= 0.16.4",
9
+ ]
10
+ description = "Satori Protocol SDK for python, adapter for OneBot 11"
11
+ readme = "README.md"
12
+ requires-python = ">=3.9"
13
+ classifiers = [
14
+ "Typing :: Typed",
15
+ "Development Status :: 4 - Beta",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3.8",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Operating System :: OS Independent",
23
+ ]
24
+
25
+ [project.license]
26
+ text = "MIT"
27
+
28
+ [project.urls]
29
+ homepage = "https://github.com/RF-Tar-Railt/satori-python"
30
+ repository = "https://github.com/RF-Tar-Railt/satori-python"
31
+
32
+ [build-system]
33
+ requires = [
34
+ "mina-build<0.6,>=0.5.1",
35
+ "pdm-backend<2.4.0",
36
+ ]
37
+ build-backend = "mina.backend"
38
+
39
+ [tool.pdm.dev-dependencies]
40
+ dev = [
41
+ "isort>=5.13.2",
42
+ "black>=24.4.0",
43
+ "ruff>=0.4.1",
44
+ "pre-commit>=3.7.0",
45
+ "fix-future-annotations>=0.5.0",
46
+ "mina-build<0.6,>=0.5.1",
47
+ "pdm-mina>=0.3.2",
48
+ ]
49
+
50
+ [tool.pdm.build]
51
+ includes = [
52
+ "src/satori/adapters/onebot11",
53
+ ".mina/adapter_onebot11.toml",
54
+ ]
55
+ excludes = [
56
+ "src/satori/adapters/*",
57
+ ]
58
+
59
+ [tool.pdm.scripts.format]
60
+ composite = [
61
+ "isort ./src/ ./example/",
62
+ "black ./src/ ./example/",
63
+ "ruff check ./src/ ./example/",
64
+ ]
65
+
66
+ [tool.pdm.version]
67
+ source = "file"
68
+ path = "src/satori/__init__.py"
69
+
70
+ [tool.black]
71
+ line-length = 110
72
+ include = "\\.pyi?$"
73
+ extend-exclude = ""
74
+
75
+ [tool.isort]
76
+ profile = "black"
77
+ line_length = 110
78
+ skip_gitignore = true
79
+ extra_standard_library = [
80
+ "typing_extensions",
81
+ ]
82
+
83
+ [tool.ruff]
84
+ line-length = 110
85
+ target-version = "py39"
86
+ exclude = [
87
+ "exam.py",
88
+ ]
89
+
90
+ [tool.ruff.lint]
91
+ select = [
92
+ "E",
93
+ "W",
94
+ "F",
95
+ "UP",
96
+ "C",
97
+ "T",
98
+ "Q",
99
+ ]
100
+ ignore = [
101
+ "E402",
102
+ "F403",
103
+ "F405",
104
+ "C901",
105
+ "UP037",
106
+ ]
107
+
108
+ [tool.pyright]
109
+ pythonPlatform = "All"
110
+ pythonVersion = "3.9"
111
+ typeCheckingMode = "basic"
112
+ reportShadowedImports = false
113
+ disableBytesTypePromotions = true
@@ -0,0 +1,2 @@
1
+ from .forward import OneBot11ForwardAdapter as OneBot11ForwardAdapter
2
+ from .reverse import OneBot11ReverseAdapter as OneBot11ReverseAdapter