satori-python 0.12.0__tar.gz → 0.13.1__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 (29) hide show
  1. {satori_python-0.12.0 → satori_python-0.13.1}/PKG-INFO +12 -6
  2. {satori_python-0.12.0 → satori_python-0.13.1}/README.md +9 -4
  3. {satori_python-0.12.0 → satori_python-0.13.1}/pyproject.toml +3 -2
  4. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/__init__.py +5 -1
  5. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/client/account.py +13 -7
  6. satori_python-0.13.1/src/satori/client/account.pyi +553 -0
  7. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/client/network/util.py +12 -2
  8. satori_python-0.13.1/src/satori/client/protocol.py +767 -0
  9. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/const.py +2 -0
  10. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/element.py +31 -2
  11. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/model.py +24 -1
  12. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/server/__init__.py +131 -57
  13. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/server/adapter.py +10 -16
  14. satori_python-0.13.1/src/satori/server/formdata.py +13 -0
  15. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/server/model.py +7 -2
  16. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/server/route.py +19 -5
  17. satori_python-0.12.0/src/satori/client/account.pyi +0 -205
  18. satori_python-0.12.0/src/satori/client/session.py +0 -406
  19. {satori_python-0.12.0 → satori_python-0.13.1}/LICENSE +0 -0
  20. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/client/__init__.py +0 -0
  21. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/client/network/__init__.py +0 -0
  22. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/client/network/base.py +0 -0
  23. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/client/network/webhook.py +0 -0
  24. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/client/network/websocket.py +0 -0
  25. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/config.py +0 -0
  26. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/event.py +0 -0
  27. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/exception.py +0 -0
  28. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/parser.py +0 -0
  29. {satori_python-0.12.0 → satori_python-0.13.1}/src/satori/server/conection.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: satori-python
3
- Version: 0.12.0
3
+ Version: 0.13.1
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>
@@ -22,9 +22,10 @@ Requires-Dist: loguru>=0.7.2
22
22
  Requires-Dist: launart>=0.8.2
23
23
  Requires-Dist: typing-extensions>=4.7.0
24
24
  Requires-Dist: graia-amnesia>=0.9.0
25
- Requires-Dist: starlette>=0.37.2
25
+ Requires-Dist: starlette[python-multipart]>=0.37.2
26
26
  Requires-Dist: uvicorn[standard]>=0.28.0
27
27
  Requires-Dist: yarl>=1.9.4
28
+ Requires-Dist: python-multipart>=0.0.9
28
29
  Description-Content-Type: text/markdown
29
30
 
30
31
  # satori-python
@@ -47,6 +48,10 @@ Description-Content-Type: text/markdown
47
48
  - [Chronocat](https://chronocat.vercel.app)
48
49
  - Koishi (搭配 `@koishijs/plugin-server`)
49
50
 
51
+ ### 使用该 SDK 的框架
52
+
53
+ - [`Entari`](https://github.com/ArcletProject/Entari)
54
+
50
55
  ## 安装
51
56
 
52
57
  安装完整体:
@@ -74,14 +79,15 @@ pip install satori-python-server
74
79
  客户端:
75
80
 
76
81
  ```python
77
- from satori import Event, WebsocketsInfo
82
+ from satori import EventType, WebsocketsInfo
83
+ from satori.event import MessageEvent
78
84
  from satori.client import Account, App
79
85
 
80
86
  app = App(WebsocketsInfo(port=5140))
81
87
 
82
- @app.register
83
- async def on_message(account: Account, event: Event):
84
- if event.user and event.user.id == "xxxxxxxxxxx":
88
+ @app.register_on(EventType.MESSAGE_CREATED)
89
+ async def on_message(account: Account, event: MessageEvent):
90
+ if event.user.id == "xxxxxxxxxxx":
85
91
  await account.send(event, "Hello, World!")
86
92
 
87
93
  app.run()
@@ -18,6 +18,10 @@
18
18
  - [Chronocat](https://chronocat.vercel.app)
19
19
  - Koishi (搭配 `@koishijs/plugin-server`)
20
20
 
21
+ ### 使用该 SDK 的框架
22
+
23
+ - [`Entari`](https://github.com/ArcletProject/Entari)
24
+
21
25
  ## 安装
22
26
 
23
27
  安装完整体:
@@ -45,14 +49,15 @@ pip install satori-python-server
45
49
  客户端:
46
50
 
47
51
  ```python
48
- from satori import Event, WebsocketsInfo
52
+ from satori import EventType, WebsocketsInfo
53
+ from satori.event import MessageEvent
49
54
  from satori.client import Account, App
50
55
 
51
56
  app = App(WebsocketsInfo(port=5140))
52
57
 
53
- @app.register
54
- async def on_message(account: Account, event: Event):
55
- if event.user and event.user.id == "xxxxxxxxxxx":
58
+ @app.register_on(EventType.MESSAGE_CREATED)
59
+ async def on_message(account: Account, event: MessageEvent):
60
+ if event.user.id == "xxxxxxxxxxx":
56
61
  await account.send(event, "Hello, World!")
57
62
 
58
63
  app.run()
@@ -11,9 +11,10 @@ dependencies = [
11
11
  "launart>=0.8.2",
12
12
  "typing-extensions>=4.7.0",
13
13
  "graia-amnesia>=0.9.0",
14
- "starlette>=0.37.2",
14
+ "starlette[python-multipart]>=0.37.2",
15
15
  "uvicorn[standard]>=0.28.0",
16
16
  "yarl>=1.9.4",
17
+ "python-multipart>=0.0.9",
17
18
  ]
18
19
  requires-python = ">=3.9"
19
20
  readme = "README.md"
@@ -28,7 +29,7 @@ classifiers = [
28
29
  "Programming Language :: Python :: 3.12",
29
30
  "Operating System :: OS Independent",
30
31
  ]
31
- version = "0.12.0"
32
+ version = "0.13.1"
32
33
 
33
34
  [project.license]
34
35
  text = "MIT"
@@ -25,6 +25,7 @@ from .element import Superscript as Superscript
25
25
  from .element import Text as Text
26
26
  from .element import Underline as Underline
27
27
  from .element import Video as Video
28
+ from .element import select as select
28
29
  from .element import transform as transform
29
30
  from .model import ArgvInteraction as ArgvInteraction
30
31
  from .model import ButtonInteraction as ButtonInteraction
@@ -36,7 +37,10 @@ from .model import Login as Login
36
37
  from .model import LoginStatus as LoginStatus
37
38
  from .model import Member as Member
38
39
  from .model import MessageObject as MessageObject
40
+ from .model import PageDequeResult as PageDequeResult
41
+ from .model import PageResult as PageResult
39
42
  from .model import Role as Role
43
+ from .model import Upload as Upload
40
44
  from .model import User as User
41
45
 
42
- __version__ = "0.12.0"
46
+ __version__ = "0.13.1"
@@ -8,9 +8,9 @@ from yarl import URL
8
8
 
9
9
  from satori.model import Login
10
10
 
11
- from .session import Session
11
+ from .protocol import ApiProtocol
12
12
 
13
- TS = TypeVar("TS", bound="Session")
13
+ TP = TypeVar("TP", bound="ApiProtocol")
14
14
 
15
15
 
16
16
  @dataclass
@@ -36,17 +36,23 @@ class Account:
36
36
  self_id: str,
37
37
  self_info: Login,
38
38
  config: ApiInfo,
39
- session_cls: type[Session] = Session,
39
+ protocol_cls: type[ApiProtocol] = ApiProtocol,
40
40
  ):
41
41
  self.platform = platform
42
42
  self.self_id = self_id
43
43
  self.self_info = self_info
44
44
  self.config = config
45
- self.session = session_cls(self) # type: ignore
45
+ self.protocol = protocol_cls(self) # type: ignore
46
46
  self.connected = asyncio.Event()
47
47
 
48
- def custom(self, config: ApiInfo | None = None, session_cls: type[TS] = Session, **kwargs) -> TS:
49
- return Account(self.platform, self.self_id, config or ApiInfo(**kwargs), session_cls).session # type: ignore
48
+ def custom(self, config: ApiInfo | None = None, protocol_cls: type[TP] = ApiProtocol, **kwargs) -> TP:
49
+ return Account(
50
+ self.platform,
51
+ self.self_id,
52
+ self.self_info,
53
+ config or ApiInfo(**kwargs),
54
+ protocol_cls, # type: ignore
55
+ ).protocol
50
56
 
51
57
  @property
52
58
  def identity(self):
@@ -56,4 +62,4 @@ class Account:
56
62
  return f"<Account {self.self_id} ({self.platform})>"
57
63
 
58
64
  def __getattr__(self, item):
59
- return getattr(self.session, item)
65
+ return getattr(self.protocol, item)