satori-python 0.15.1__tar.gz → 0.15.2__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-0.15.1 → satori_python-0.15.2}/PKG-INFO +1 -1
- {satori_python-0.15.1 → satori_python-0.15.2}/pyproject.toml +1 -1
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/__init__.py +1 -1
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/client/__init__.py +5 -1
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/client/account.py +3 -1
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/client/network/webhook.py +1 -1
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/client/network/websocket.py +1 -1
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/model.py +8 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/LICENSE +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/README.md +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/client/account.pyi +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/client/network/__init__.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/client/network/base.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/client/network/util.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/client/protocol.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/config.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/const.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/element.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/event.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/exception.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/parser.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/server/__init__.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/server/adapter.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/server/conection.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/server/formdata.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/server/model.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/server/route.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/server/utils.py +0 -0
- {satori_python-0.15.1 → satori_python-0.15.2}/src/satori/utils.py +0 -0
|
@@ -23,6 +23,7 @@ from .account import ApiInfo as ApiInfo
|
|
|
23
23
|
from .network.base import BaseNetwork as BaseNetwork
|
|
24
24
|
from .network.webhook import WebhookNetwork
|
|
25
25
|
from .network.websocket import WsNetwork
|
|
26
|
+
from .protocol import ApiProtocol as ApiProtocol
|
|
26
27
|
|
|
27
28
|
TConfig = TypeVar("TConfig", bound=Config)
|
|
28
29
|
TE = TypeVar("TE", bound=Event, contravariant=True)
|
|
@@ -47,7 +48,7 @@ class App(Service):
|
|
|
47
48
|
def register_config(cls, tc: type[TConfig], tn: type[BaseNetwork[TConfig]]):
|
|
48
49
|
MAPPING[tc] = tn
|
|
49
50
|
|
|
50
|
-
def __init__(self, *configs: Config):
|
|
51
|
+
def __init__(self, *configs: Config, default_api_cls: type[ApiProtocol] = ApiProtocol):
|
|
51
52
|
self.accounts = {}
|
|
52
53
|
self.connections = []
|
|
53
54
|
self.event_callbacks = []
|
|
@@ -55,6 +56,7 @@ class App(Service):
|
|
|
55
56
|
super().__init__()
|
|
56
57
|
for config in configs:
|
|
57
58
|
self.apply(config)
|
|
59
|
+
self.default_api_cls = default_api_cls
|
|
58
60
|
|
|
59
61
|
def apply(self, config: Config):
|
|
60
62
|
try:
|
|
@@ -195,6 +197,7 @@ class App(Service):
|
|
|
195
197
|
event.self_id_,
|
|
196
198
|
event.login,
|
|
197
199
|
conn.config,
|
|
200
|
+
self.default_api_cls,
|
|
198
201
|
)
|
|
199
202
|
logger.info(f"account added: {account}")
|
|
200
203
|
(
|
|
@@ -215,6 +218,7 @@ class App(Service):
|
|
|
215
218
|
event.self_id_,
|
|
216
219
|
event.login,
|
|
217
220
|
conn.config,
|
|
221
|
+
self.default_api_cls,
|
|
218
222
|
)
|
|
219
223
|
logger.info(f"account added: {account}")
|
|
220
224
|
account.connected.set()
|
|
@@ -79,4 +79,6 @@ class Account(Generic[TP]):
|
|
|
79
79
|
return f"<Account {self.self_id} ({self.platform})>"
|
|
80
80
|
|
|
81
81
|
def __getattr__(self, item):
|
|
82
|
-
|
|
82
|
+
if hasattr(self.protocol, item):
|
|
83
|
+
return getattr(self.protocol, item)
|
|
84
|
+
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{item}'")
|
|
@@ -59,7 +59,7 @@ class WebhookNetwork(BaseNetwork[WebhookInfo]):
|
|
|
59
59
|
(i for i in logins if i.id == self_id and i.platform == platform),
|
|
60
60
|
Login(LoginStatus.CONNECT, self_id=self_id, platform=platform),
|
|
61
61
|
)
|
|
62
|
-
account = Account(platform, self_id, login, self.config)
|
|
62
|
+
account = Account(platform, self_id, login, self.config, self.app.default_api_cls)
|
|
63
63
|
logger.info(f"account registered: {account}")
|
|
64
64
|
account.connected.set()
|
|
65
65
|
self.app.accounts[identity] = account
|
|
@@ -101,7 +101,7 @@ class WsNetwork(BaseNetwork[WebsocketsInfo]):
|
|
|
101
101
|
account.connected.clear()
|
|
102
102
|
account.config = self.config
|
|
103
103
|
else:
|
|
104
|
-
account = Account(platform, self_id, obj, self.config)
|
|
104
|
+
account = Account(platform, self_id, obj, self.config, self.app.default_api_cls)
|
|
105
105
|
logger.info(f"account registered: {account}")
|
|
106
106
|
(
|
|
107
107
|
account.connected.set()
|
|
@@ -260,6 +260,10 @@ class MessageObject(ModelBase):
|
|
|
260
260
|
def message(self) -> list[Element]:
|
|
261
261
|
return transform(parse(self.content))
|
|
262
262
|
|
|
263
|
+
@message.setter
|
|
264
|
+
def message(self, value: list[Element]):
|
|
265
|
+
self.content = "".join(str(i) for i in value)
|
|
266
|
+
|
|
263
267
|
@classmethod
|
|
264
268
|
def parse(cls, raw: dict):
|
|
265
269
|
if "elements" in raw and "content" not in raw:
|
|
@@ -310,6 +314,10 @@ class MessageReceipt(ModelBase):
|
|
|
310
314
|
def message(self) -> Optional[list[Element]]:
|
|
311
315
|
return transform(parse(self.content)) if self.content else None
|
|
312
316
|
|
|
317
|
+
@message.setter
|
|
318
|
+
def message(self, value: Optional[list[Element]]):
|
|
319
|
+
self.content = "".join(str(i) for i in value) if value else None
|
|
320
|
+
|
|
313
321
|
@classmethod
|
|
314
322
|
def parse(cls, raw: dict):
|
|
315
323
|
if "elements" in raw and "content" not in raw:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|