satori-python-server 0.17.6__tar.gz → 0.18.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.
@@ -1,5 +1,5 @@
1
1
  includes = ["src/satori/server"]
2
- raw-dependencies = ["satori-python-core >= 0.17.0"]
2
+ raw-dependencies = ["satori-python-core >=0.18.0"]
3
3
 
4
4
  [project]
5
5
  name = "satori-python-server"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: satori-python-server
3
- Version: 0.17.6
3
+ Version: 0.18.0
4
4
  Summary: Satori Protocol SDK for python, specify server part
5
5
  Home-page: https://github.com/RF-Tar-Railt/satori-python
6
6
  Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
@@ -23,7 +23,7 @@ Requires-Dist: graia-amnesia[uvicorn]<0.12.0,>=0.11.0
23
23
  Requires-Dist: starlette>=0.40.0
24
24
  Requires-Dist: websockets>=15.0.1
25
25
  Requires-Dist: python-multipart>=0.0.9
26
- Requires-Dist: satori-python-core>=0.17.0
26
+ Requires-Dist: satori-python-core>=0.18.0
27
27
  Description-Content-Type: text/markdown
28
28
 
29
29
  # satori-python
@@ -33,17 +33,18 @@ Description-Content-Type: text/markdown
33
33
  [![PyPI](https://img.shields.io/pypi/v/satori-python)](https://pypi.org/project/satori-python)
34
34
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/satori-python)](https://www.python.org/)
35
35
 
36
- 基于 [Satori](https://satori.js.org/zh-CN/) 协议的 Python 开发工具包
36
+ 基于 [Satori](https://satori.chat/zh-CN/) 协议的 Python 开发工具包
37
37
 
38
38
  ## 协议介绍
39
39
 
40
- [Satori Protocol](https://satori.js.org/zh-CN/)
40
+ [Satori Protocol](https://satori.chat/zh-CN/)
41
41
 
42
42
  ### 协议端
43
43
 
44
44
  目前提供了 `satori` 协议实现的有:
45
45
 
46
46
  - [Chronocat](https://chronocat.vercel.app)
47
+ - [LLBot](https://www.llonebot.com/guide/introduction)
47
48
  - [nekobox](https://github.com/wyapx/nekobox)
48
49
  - Koishi (搭配 `@koishijs/plugin-server`)
49
50
 
@@ -81,6 +82,7 @@ pip install satori-python-server
81
82
  | OneBot V11 | `pip install satori-python-adapter-onebot11` | satori.adapters.onebot11.forward, satori.adapters.onebot11.reverse |
82
83
  | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
83
84
  | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook |
85
+ | QQ | `pip install satori-python-adapter-qq` | satori.adapters.milky.main, satori.adapters.milky.websocket |
84
86
 
85
87
  ### 社区适配器
86
88
 
@@ -5,17 +5,18 @@
5
5
  [![PyPI](https://img.shields.io/pypi/v/satori-python)](https://pypi.org/project/satori-python)
6
6
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/satori-python)](https://www.python.org/)
7
7
 
8
- 基于 [Satori](https://satori.js.org/zh-CN/) 协议的 Python 开发工具包
8
+ 基于 [Satori](https://satori.chat/zh-CN/) 协议的 Python 开发工具包
9
9
 
10
10
  ## 协议介绍
11
11
 
12
- [Satori Protocol](https://satori.js.org/zh-CN/)
12
+ [Satori Protocol](https://satori.chat/zh-CN/)
13
13
 
14
14
  ### 协议端
15
15
 
16
16
  目前提供了 `satori` 协议实现的有:
17
17
 
18
18
  - [Chronocat](https://chronocat.vercel.app)
19
+ - [LLBot](https://www.llonebot.com/guide/introduction)
19
20
  - [nekobox](https://github.com/wyapx/nekobox)
20
21
  - Koishi (搭配 `@koishijs/plugin-server`)
21
22
 
@@ -53,6 +54,7 @@ pip install satori-python-server
53
54
  | OneBot V11 | `pip install satori-python-adapter-onebot11` | satori.adapters.onebot11.forward, satori.adapters.onebot11.reverse |
54
55
  | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
55
56
  | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook |
57
+ | QQ | `pip install satori-python-adapter-qq` | satori.adapters.milky.main, satori.adapters.milky.websocket |
56
58
 
57
59
  ### 社区适配器
58
60
 
@@ -11,7 +11,7 @@ dependencies = [
11
11
  "starlette>=0.40.0",
12
12
  "websockets>=15.0.1",
13
13
  "python-multipart>=0.0.9",
14
- "satori-python-core >= 0.17.0",
14
+ "satori-python-core >=0.18.0",
15
15
  ]
16
16
  description = "Satori Protocol SDK for python, specify server part"
17
17
  readme = "README.md"
@@ -27,7 +27,7 @@ classifiers = [
27
27
  "Programming Language :: Python :: 3.12",
28
28
  "Operating System :: OS Independent",
29
29
  ]
30
- version = "0.17.6"
30
+ version = "0.18.0"
31
31
 
32
32
  [project.license]
33
33
  text = "MIT"
@@ -40,6 +40,7 @@ from starlette.websockets import WebSocket, WebSocketDisconnect
40
40
  from yarl import URL
41
41
 
42
42
  from satori.const import Api, EventType
43
+ from satori.exception import ActionFailed
43
44
  from satori.model import Event, Meta, ModelBase, Opcode
44
45
  from satori.utils import decode
45
46
 
@@ -96,6 +97,9 @@ async def _request_handler(action: str, request: StarletteRequest, func: RouteCa
96
97
  self_id=self_id,
97
98
  )
98
99
  )
100
+ except ActionFailed as ae:
101
+ logger.warning(ae)
102
+ return Response(status_code=ae.CODE, content=str(ae))
99
103
  except Exception as e:
100
104
  logger.error(e)
101
105
  return Response(status_code=500, content=str(e))
@@ -139,7 +143,6 @@ class Server(Service, RouterMixin):
139
143
  self.port = port
140
144
  self.version = version
141
145
  self.path = path
142
- self.uvicorn_options = uvicorn_options
143
146
  if self.path and not self.path.startswith("/"):
144
147
  self.path = f"/{self.path}"
145
148
  if (self.host == "0.0.0.0" or self.host == "::") and not token:
@@ -157,9 +160,13 @@ class Server(Service, RouterMixin):
157
160
  self.stream_chunk_size = stream_chunk_size
158
161
  self.resources: dict[str, Path] = {}
159
162
  self.app = Starlette()
160
- self.asgi_service = UvicornASGIService(self.host, self.port, options=self.uvicorn_options)
163
+ self.asgi_service = UvicornASGIService(self.host, self.port, options=uvicorn_options)
161
164
  super().__init__()
162
165
 
166
+ @property
167
+ def uvicorn_options(self) -> UvicornOptions:
168
+ return self.asgi_service.options
169
+
163
170
  def replace_app(self, app: ASGIApp | asgitypes.ASGI3Application):
164
171
  """替换当前的 Starlette 应用"""
165
172
  self.app = app
@@ -332,7 +339,9 @@ class Server(Service, RouterMixin):
332
339
  else:
333
340
  continue
334
341
  return await _request_handler(action, request, func, platform, self_id)
335
- return Response(status_code=404, content=action)
342
+ return Response(
343
+ status_code=404, content=f"Action {action!r} is not supported in current platform {platform!r}."
344
+ )
336
345
 
337
346
  async def proxy_url_handler(self, request: StarletteRequest):
338
347
  url = request.path_params["internal_url"]
@@ -36,6 +36,7 @@ INTERAL: TypeAlias = RouteCall[Any, ModelBase | list[ModelBase] | dict[str, Any]
36
36
  class MessageParam(TypedDict):
37
37
  channel_id: str
38
38
  content: str
39
+ referrer: NotRequired[dict[str, Any]]
39
40
 
40
41
 
41
42
  MESSAGE_CREATE: TypeAlias = RouteCall[MessageParam, list[MessageObject] | list[dict[str, Any]]]
@@ -179,7 +180,7 @@ GUILD_ROLE_LIST: TypeAlias = RouteCall[GuildXXXListParam, PageResult[Role] | dic
179
180
 
180
181
 
181
182
  class GuildRoleCreateParam(TypedDict):
182
- guild: str
183
+ guild_id: str
183
184
  role: dict
184
185
 
185
186
 
@@ -187,7 +188,7 @@ GUILD_ROLE_CREATE: TypeAlias = RouteCall[GuildRoleCreateParam, Role | dict[str,
187
188
 
188
189
 
189
190
  class GuildRoleUpdateParam(TypedDict):
190
- guild: str
191
+ guild_id: str
191
192
  role_id: str
192
193
  role: dict
193
194
 
@@ -196,7 +197,7 @@ GUILD_ROLE_UPDATE: TypeAlias = RouteCall[GuildRoleUpdateParam, None]
196
197
 
197
198
 
198
199
  class GuildRoleDeleteParam(TypedDict):
199
- guild: str
200
+ guild_id: str
200
201
  role_id: str
201
202
 
202
203