satori-python 1.3.9__tar.gz → 1.3.10__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.
Files changed (31) hide show
  1. {satori_python-1.3.9 → satori_python-1.3.10}/PKG-INFO +3 -1
  2. {satori_python-1.3.9 → satori_python-1.3.10}/README.md +1 -0
  3. {satori_python-1.3.9 → satori_python-1.3.10}/pyproject.toml +2 -1
  4. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/__init__.py +1 -1
  5. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/__init__.py +4 -4
  6. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/network/webhook.py +2 -2
  7. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/network/websocket.py +2 -2
  8. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/model.py +5 -1
  9. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/server/__init__.py +3 -1
  10. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/server/adapter.py +5 -6
  11. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/server/utils.py +2 -2
  12. {satori_python-1.3.9 → satori_python-1.3.10}/LICENSE +0 -0
  13. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/_vendor/fleep.py +0 -0
  14. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/account.py +0 -0
  15. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/account.pyi +0 -0
  16. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/config.py +0 -0
  17. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/network/__init__.py +0 -0
  18. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/network/base.py +0 -0
  19. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/network/util.py +0 -0
  20. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/client/protocol.py +0 -0
  21. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/const.py +0 -0
  22. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/element.py +0 -0
  23. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/event.py +0 -0
  24. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/exception.py +0 -0
  25. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/parser.py +0 -0
  26. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/py.typed +0 -0
  27. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/server/connection.py +0 -0
  28. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/server/formdata.py +0 -0
  29. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/server/model.py +0 -0
  30. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/server/route.py +0 -0
  31. {satori_python-1.3.9 → satori_python-1.3.10}/src/satori/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: satori-python
3
- Version: 1.3.9
3
+ Version: 1.3.10
4
4
  Summary: Satori Protocol SDK for python
5
5
  Home-page: https://github.com/RF-Tar-Railt/satori-python
6
6
  Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Programming Language :: Python :: 3.15
16
17
  Classifier: Operating System :: OS Independent
17
18
  Project-URL: Homepage, https://github.com/RF-Tar-Railt/satori-python
18
19
  Project-URL: Repository, https://github.com/RF-Tar-Railt/satori-python
@@ -88,6 +89,7 @@ pip install satori-python-server
88
89
  | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
89
90
  | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook, satori.adapters.milky.sse |
90
91
  | QQ | `pip install satori-python-adapter-qq` | satori.adapters.qq.main, satori.adapters.qq.websocket |
92
+ | WxClaw | `pip install satori-python-adapter-wxclaw` | satori.adapters.wxclaw |
91
93
 
92
94
  ### 社区适配器
93
95
 
@@ -55,6 +55,7 @@ pip install satori-python-server
55
55
  | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
56
56
  | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook, satori.adapters.milky.sse |
57
57
  | QQ | `pip install satori-python-adapter-qq` | satori.adapters.qq.main, satori.adapters.qq.websocket |
58
+ | WxClaw | `pip install satori-python-adapter-wxclaw` | satori.adapters.wxclaw |
58
59
 
59
60
  ### 社区适配器
60
61
 
@@ -28,9 +28,10 @@ classifiers = [
28
28
  "Programming Language :: Python :: 3.12",
29
29
  "Programming Language :: Python :: 3.13",
30
30
  "Programming Language :: Python :: 3.14",
31
+ "Programming Language :: Python :: 3.15",
31
32
  "Operating System :: OS Independent",
32
33
  ]
33
- version = "1.3.9"
34
+ version = "1.3.10"
34
35
 
35
36
  [project.license]
36
37
  text = "MIT"
@@ -45,7 +45,7 @@ from .model import Role as Role
45
45
  from .model import Upload as Upload
46
46
  from .model import User as User
47
47
 
48
- __version__ = "1.3.9"
48
+ __version__ = "1.3.10"
49
49
 
50
50
 
51
51
  MessageReceipt = MessageObject
@@ -237,7 +237,7 @@ class App(Service):
237
237
  if not login.user:
238
238
  logger.warning(f"Received login-added event without user info: {login}")
239
239
  return
240
- login_sn = f"{login.platform}_{login.user.id}@{id(conn):x}"
240
+ login_sn = login.identifier
241
241
  account = Account(
242
242
  login,
243
243
  conn.config,
@@ -256,7 +256,7 @@ class App(Service):
256
256
  if not login.user:
257
257
  logger.warning(f"Received login-updated event without user info: {login}")
258
258
  return
259
- login_sn = f"{login.platform}_{login.user.id}@{id(conn):x}"
259
+ login_sn = login.identifier
260
260
  if login_sn not in self.accounts:
261
261
  if login.status != LoginStatus.ONLINE:
262
262
  logger.warning(f"Received event for unknown account: {event}")
@@ -289,13 +289,13 @@ class App(Service):
289
289
  if not login.user:
290
290
  logger.warning(f"Received login-removed event without user info: {login}")
291
291
  return
292
- login_sn = f"{login.platform}_{login.user.id}@{id(conn):x}"
292
+ login_sn = login.identifier
293
293
  if login_sn not in self.accounts:
294
294
  logger.warning(f"Received event for unknown account: {event}")
295
295
  return
296
296
  account = self.accounts[login_sn]
297
297
  else:
298
- login_sn = f"{event.login.platform}_{event.login.user.id}@{id(conn):x}"
298
+ login_sn = event.login.identifier
299
299
  if login_sn not in self.accounts:
300
300
  logger.warning(f"Received event for unknown account: {event}")
301
301
  return
@@ -105,7 +105,7 @@ class WebhookNetwork(BaseNetwork[WebhookInfo]):
105
105
  for login in meta.logins:
106
106
  if not login.user:
107
107
  continue
108
- login_sn = f"{login.platform}_{login.user.id}@{id(self):x}"
108
+ login_sn = login.identifier
109
109
  account = Account(login, self.config, meta.proxy_urls, self.app.default_api_cls)
110
110
  logger.info(f"account registered: {account}")
111
111
  (account.connected.set() if login.status == LoginStatus.ONLINE else account.connected.clear())
@@ -117,7 +117,7 @@ class WebhookNetwork(BaseNetwork[WebhookInfo]):
117
117
  logger.info(f"{self.id} Webhook server exiting...")
118
118
  self.close_signal.set()
119
119
  for v in list(self.app.accounts.values()):
120
- if (identity := f"{v.platform}_{v.self_id}@{id(self):x}") in self.accounts:
120
+ if (identity := v.self_info.identifier) in self.accounts:
121
121
  v.connected.clear()
122
122
  await self.app.account_update(v, LoginStatus.OFFLINE)
123
123
  del self.app.accounts[identity]
@@ -110,7 +110,7 @@ class WsNetwork(BaseNetwork[WebsocketsInfo]):
110
110
  for login in ready.logins:
111
111
  if not login.user:
112
112
  continue
113
- login_sn = f"{login.platform}_{login.user.id}@{id(self):x}"
113
+ login_sn = login.identifier
114
114
  if login_sn in self.app.accounts:
115
115
  account = self.app.accounts[login_sn]
116
116
  self.accounts[login_sn] = account
@@ -167,7 +167,7 @@ class WsNetwork(BaseNetwork[WebsocketsInfo]):
167
167
  self.close_signal.set()
168
168
  self.connection = None
169
169
  for v in list(self.app.accounts.values()):
170
- if (identity := f"{v.platform}_{v.self_id}@{id(self):x}") in self.accounts:
170
+ if (identity := v.self_info.identifier) in self.accounts:
171
171
  v.connected.clear()
172
172
  await self.app.account_update(v, LoginStatus.OFFLINE)
173
173
  del self.app.accounts[identity]
@@ -46,7 +46,7 @@ class ModelBase:
46
46
  def __init_subclass__(cls, **kwargs):
47
47
  has_converter = False
48
48
  keys = set()
49
- for c in cls.__mro__[-1:0:-1]:
49
+ for c in cls.__mro__[-1::-1]:
50
50
  if c is Generic:
51
51
  _generic_init_subclass(cls, **kwargs)
52
52
  if getattr(c, "__converter__", None):
@@ -258,6 +258,10 @@ class Login(ModelBase):
258
258
  def id(self) -> str:
259
259
  return self.user.id
260
260
 
261
+ @property
262
+ def identifier(self) -> str:
263
+ return f"{self.platform}:{self.adapter}_{self.user.id}#{self.sn}"
264
+
261
265
 
262
266
  @dataclass(slots=True)
263
267
  class LoginPartial(Login):
@@ -70,7 +70,9 @@ async def _json(self: StarletteRequest) -> Any:
70
70
  StarletteRequest.json = _json
71
71
 
72
72
 
73
- async def _request_handler(action: str, request: StarletteRequest, func: RouteCall, platform: str, self_id: str):
73
+ async def _request_handler(
74
+ action: str, request: StarletteRequest, func: RouteCall[Any, Any], platform: str, self_id: str
75
+ ):
74
76
  if action == Api.UPLOAD_CREATE:
75
77
  async with request.form() as form:
76
78
  res = await func(
@@ -1,21 +1,20 @@
1
1
  from abc import abstractmethod
2
- from typing import TYPE_CHECKING, Generic, TypeVar, Union
2
+ from typing import TYPE_CHECKING, Generic, TypeVar
3
3
 
4
4
  from launart import Service
5
5
  from starlette.responses import Response
6
6
  from starlette.routing import BaseRoute
7
7
 
8
- from satori.model import Login, LoginPartial
8
+ from satori.model import Login
9
9
 
10
10
  from .model import Request
11
11
  from .route import RouterMixin
12
- from .utils import ctx
12
+ from .utils import SSL_CTX
13
13
 
14
14
  if TYPE_CHECKING:
15
15
  from . import Server
16
16
 
17
17
 
18
- LoginType = Union[Login, LoginPartial] # noqa: UP007
19
18
  T = TypeVar("T")
20
19
 
21
20
 
@@ -41,11 +40,11 @@ class Adapter(Service, RouterMixin, Generic[T]):
41
40
  async def handle_internal(self, request: Request, path: str) -> Response: ...
42
41
 
43
42
  async def handle_proxied(self, prefix: str, url: str) -> Response | None:
44
- async with self.server.session.get(url, ssl=ctx) as resp:
43
+ async with self.server.session.get(url, ssl=SSL_CTX) as resp:
45
44
  return Response(await resp.read())
46
45
 
47
46
  @abstractmethod
48
- async def get_logins(self) -> list[LoginType]: ...
47
+ async def get_logins(self) -> list[Login]: ...
49
48
 
50
49
  def __init__(self):
51
50
  super().__init__()
@@ -24,8 +24,8 @@ class Deque:
24
24
  return list(self.data)[i + 1 - self.offset :]
25
25
 
26
26
 
27
- ctx = ssl.create_default_context()
28
- ctx.set_ciphers("DEFAULT")
27
+ SSL_CTX = ssl.create_default_context()
28
+ SSL_CTX.set_ciphers("DEFAULT")
29
29
 
30
30
 
31
31
  if __name__ == "__main__":
File without changes