satori-python-client 0.13.2__tar.gz → 0.14.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.
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/PKG-INFO +1 -1
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/pyproject.toml +3 -3
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/__init__.py +2 -1
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/account.py +9 -6
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/account.pyi +11 -7
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/webhook.py +1 -1
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/websocket.py +3 -3
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/protocol.py +2 -1
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/.mina/client.toml +0 -0
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/LICENSE +0 -0
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/README.md +0 -0
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/__init__.py +0 -0
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/base.py +0 -0
- {satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/util.py +0 -0
|
@@ -24,7 +24,7 @@ classifiers = [
|
|
|
24
24
|
"Programming Language :: Python :: 3.12",
|
|
25
25
|
"Operating System :: OS Independent",
|
|
26
26
|
]
|
|
27
|
-
version = "0.
|
|
27
|
+
version = "0.14.0"
|
|
28
28
|
|
|
29
29
|
[project.license]
|
|
30
30
|
text = "MIT"
|
|
@@ -82,7 +82,7 @@ extra_standard_library = [
|
|
|
82
82
|
|
|
83
83
|
[tool.ruff]
|
|
84
84
|
line-length = 110
|
|
85
|
-
target-version = "
|
|
85
|
+
target-version = "py39"
|
|
86
86
|
exclude = [
|
|
87
87
|
"exam.py",
|
|
88
88
|
]
|
|
@@ -107,7 +107,7 @@ ignore = [
|
|
|
107
107
|
|
|
108
108
|
[tool.pyright]
|
|
109
109
|
pythonPlatform = "All"
|
|
110
|
-
pythonVersion = "3.
|
|
110
|
+
pythonVersion = "3.9"
|
|
111
111
|
typeCheckingMode = "basic"
|
|
112
112
|
reportShadowedImports = false
|
|
113
113
|
disableBytesTypePromotions = true
|
|
@@ -4,8 +4,9 @@ import asyncio
|
|
|
4
4
|
import functools
|
|
5
5
|
import signal
|
|
6
6
|
import threading
|
|
7
|
+
from collections.abc import Awaitable, Iterable
|
|
7
8
|
from functools import wraps
|
|
8
|
-
from typing import TYPE_CHECKING, Any,
|
|
9
|
+
from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, overload
|
|
9
10
|
|
|
10
11
|
from creart import it
|
|
11
12
|
from graia.amnesia.builtins.aiohttp import AiohttpClientService
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
from dataclasses import dataclass
|
|
5
|
-
from typing import TypeVar
|
|
5
|
+
from typing import Generic, TypeVar
|
|
6
6
|
|
|
7
7
|
from yarl import URL
|
|
8
8
|
|
|
@@ -11,6 +11,7 @@ from satori.model import Login
|
|
|
11
11
|
from .protocol import ApiProtocol
|
|
12
12
|
|
|
13
13
|
TP = TypeVar("TP", bound="ApiProtocol")
|
|
14
|
+
TP1 = TypeVar("TP1", bound="ApiProtocol")
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
@dataclass
|
|
@@ -29,14 +30,14 @@ class ApiInfo:
|
|
|
29
30
|
return URL(f"http://{self.host}:{self.port}{self.path}") / "v1"
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
class Account:
|
|
33
|
+
class Account(Generic[TP]):
|
|
33
34
|
def __init__(
|
|
34
35
|
self,
|
|
35
36
|
platform: str,
|
|
36
37
|
self_id: str,
|
|
37
38
|
self_info: Login,
|
|
38
39
|
config: ApiInfo,
|
|
39
|
-
protocol_cls: type[
|
|
40
|
+
protocol_cls: type[TP] = ApiProtocol,
|
|
40
41
|
):
|
|
41
42
|
self.platform = platform
|
|
42
43
|
self.self_id = self_id
|
|
@@ -45,14 +46,16 @@ class Account:
|
|
|
45
46
|
self.protocol = protocol_cls(self) # type: ignore
|
|
46
47
|
self.connected = asyncio.Event()
|
|
47
48
|
|
|
48
|
-
def custom(
|
|
49
|
+
def custom(
|
|
50
|
+
self, config: ApiInfo | None = None, protocol_cls: type[TP1] = ApiProtocol, **kwargs
|
|
51
|
+
) -> "Account[TP1]":
|
|
49
52
|
return Account(
|
|
50
53
|
self.platform,
|
|
51
54
|
self.self_id,
|
|
52
55
|
self.self_info,
|
|
53
|
-
config or ApiInfo(**kwargs),
|
|
56
|
+
config or (ApiInfo(**kwargs) if kwargs else self.config),
|
|
54
57
|
protocol_cls, # type: ignore
|
|
55
|
-
)
|
|
58
|
+
)
|
|
56
59
|
|
|
57
60
|
@property
|
|
58
61
|
def identity(self):
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
from
|
|
2
|
+
from collections.abc import Iterable
|
|
3
|
+
from typing import Any, Generic, Protocol, TypeVar, overload
|
|
3
4
|
|
|
4
5
|
from yarl import URL
|
|
5
6
|
|
|
@@ -23,6 +24,7 @@ from satori.model import (
|
|
|
23
24
|
from .protocol import ApiProtocol
|
|
24
25
|
|
|
25
26
|
TP = TypeVar("TP", bound="ApiProtocol")
|
|
27
|
+
TP1 = TypeVar("TP1", bound="ApiProtocol")
|
|
26
28
|
|
|
27
29
|
class Api(Protocol):
|
|
28
30
|
token: str | None = None
|
|
@@ -35,12 +37,12 @@ class ApiInfo(Api):
|
|
|
35
37
|
self, host: str = "localhost", port: int = 5140, path: str = "", token: str | None = None
|
|
36
38
|
): ...
|
|
37
39
|
|
|
38
|
-
class Account:
|
|
40
|
+
class Account(Generic[TP]):
|
|
39
41
|
platform: str
|
|
40
42
|
self_id: str
|
|
41
43
|
self_info: Login
|
|
42
44
|
config: Api
|
|
43
|
-
protocol:
|
|
45
|
+
protocol: TP
|
|
44
46
|
connected: asyncio.Event
|
|
45
47
|
|
|
46
48
|
def __init__(
|
|
@@ -49,16 +51,18 @@ class Account:
|
|
|
49
51
|
self_id: str,
|
|
50
52
|
self_info: Login,
|
|
51
53
|
config: Api,
|
|
52
|
-
protocol_cls: type[
|
|
54
|
+
protocol_cls: type[TP] = ApiProtocol,
|
|
53
55
|
): ...
|
|
54
56
|
@property
|
|
55
57
|
def identity(self) -> str: ...
|
|
56
58
|
@overload
|
|
57
|
-
def custom(self, config: Api, protocol_cls: type[
|
|
59
|
+
def custom(self, config: Api, protocol_cls: type[TP1] = ApiProtocol) -> Account[TP1]: ...
|
|
60
|
+
@overload
|
|
61
|
+
def custom(self, *, protocol_cls: type[TP1]) -> Account[TP1]: ...
|
|
58
62
|
@overload
|
|
59
63
|
def custom(
|
|
60
|
-
self, *, protocol_cls: type[
|
|
61
|
-
) ->
|
|
64
|
+
self, *, protocol_cls: type[TP1] = ApiProtocol, host: str, port: int, token: str | None = None
|
|
65
|
+
) -> Account[TP1]: ...
|
|
62
66
|
async def send(self, event: Event, message: str | Iterable[str | Element]) -> list[MessageObject]:
|
|
63
67
|
"""发送消息。返回一个 `MessageObject` 对象构成的数组。
|
|
64
68
|
|
{satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/webhook.py
RENAMED
|
@@ -61,7 +61,7 @@ class WebhookNetwork(BaseNetwork[WebhookInfo]):
|
|
|
61
61
|
op = data["op"]
|
|
62
62
|
if op != Opcode.EVENT:
|
|
63
63
|
return web.Response(status=202)
|
|
64
|
-
logger.
|
|
64
|
+
logger.trace(f"Received payload: {data}")
|
|
65
65
|
self.post_event(data["body"])
|
|
66
66
|
return web.Response()
|
|
67
67
|
|
{satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/websocket.py
RENAMED
|
@@ -37,6 +37,7 @@ class WsNetwork(BaseNetwork[WebsocketsInfo]):
|
|
|
37
37
|
return
|
|
38
38
|
elif msg.type == aiohttp.WSMsgType.TEXT:
|
|
39
39
|
data: dict = json.loads(cast(str, msg.data))
|
|
40
|
+
logger.trace(f"Received payload: {data}")
|
|
40
41
|
if data["op"] == Opcode.EVENT:
|
|
41
42
|
self.post_event(data["body"])
|
|
42
43
|
elif data["op"] > 4:
|
|
@@ -118,9 +119,8 @@ class WsNetwork(BaseNetwork[WebsocketsInfo]):
|
|
|
118
119
|
async def _heartbeat(self):
|
|
119
120
|
"""心跳"""
|
|
120
121
|
while True:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
await self.send({"op": 1})
|
|
122
|
+
with suppress(Exception):
|
|
123
|
+
await self.send({"op": 1})
|
|
124
124
|
await asyncio.sleep(9)
|
|
125
125
|
|
|
126
126
|
async def daemon(self, manager: Launart, session: aiohttp.ClientSession):
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from collections.abc import Iterable
|
|
4
|
+
from typing import TYPE_CHECKING, Any, cast, overload
|
|
4
5
|
|
|
5
6
|
from aiohttp import FormData
|
|
6
7
|
from graia.amnesia.builtins.aiohttp import AiohttpClientService
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/__init__.py
RENAMED
|
File without changes
|
{satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/base.py
RENAMED
|
File without changes
|
{satori_python_client-0.13.2 → satori_python_client-0.14.0}/src/satori/client/network/util.py
RENAMED
|
File without changes
|