satori-python-core 0.16.1__tar.gz → 0.16.3__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_core-0.16.1 → satori_python_core-0.16.3}/PKG-INFO +1 -1
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/pyproject.toml +1 -1
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/src/satori/__init__.py +1 -1
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/src/satori/event.py +2 -2
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/src/satori/model.py +42 -10
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/.mina/core.toml +0 -0
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/LICENSE +0 -0
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/README.md +0 -0
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/src/satori/const.py +0 -0
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/src/satori/element.py +0 -0
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/src/satori/exception.py +0 -0
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/src/satori/parser.py +0 -0
- {satori_python_core-0.16.1 → satori_python_core-0.16.3}/src/satori/utils.py +0 -0
|
@@ -4,7 +4,7 @@ from satori.model import (
|
|
|
4
4
|
Channel,
|
|
5
5
|
Event,
|
|
6
6
|
Guild,
|
|
7
|
-
|
|
7
|
+
LoginPartial,
|
|
8
8
|
Member,
|
|
9
9
|
MessageObject,
|
|
10
10
|
Role,
|
|
@@ -37,7 +37,7 @@ class GuildRoleEvent(GuildEvent):
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
class LoginEvent(Event):
|
|
40
|
-
login:
|
|
40
|
+
login: LoginPartial
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
class ReactionEvent(Event):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import mimetypes
|
|
2
|
+
from collections.abc import AsyncIterable, Awaitable
|
|
2
3
|
from dataclasses import asdict, dataclass, field, fields
|
|
3
4
|
from datetime import datetime
|
|
4
5
|
from enum import IntEnum
|
|
@@ -145,11 +146,11 @@ class LoginStatus(IntEnum):
|
|
|
145
146
|
|
|
146
147
|
@dataclass
|
|
147
148
|
class Login(ModelBase):
|
|
148
|
-
sn:
|
|
149
|
+
sn: int
|
|
149
150
|
status: LoginStatus
|
|
150
151
|
adapter: str
|
|
151
|
-
platform:
|
|
152
|
-
user:
|
|
152
|
+
platform: str
|
|
153
|
+
user: User
|
|
153
154
|
features: list[str] = field(default_factory=list)
|
|
154
155
|
|
|
155
156
|
__converter__ = {"user": User.parse, "status": LoginStatus}
|
|
@@ -172,17 +173,25 @@ class Login(ModelBase):
|
|
|
172
173
|
def parse(cls, raw: dict):
|
|
173
174
|
if "self_id" in raw and "user" not in raw:
|
|
174
175
|
raw["user"] = {"id": raw["self_id"]}
|
|
176
|
+
if "sn" not in raw:
|
|
177
|
+
raw["sn"] = 0
|
|
175
178
|
if "adapter" not in raw:
|
|
176
179
|
raw["adapter"] = "satori"
|
|
180
|
+
if "status" not in raw:
|
|
181
|
+
raw["status"] = LoginStatus.ONLINE
|
|
177
182
|
return super().parse(raw)
|
|
178
183
|
|
|
179
184
|
@property
|
|
180
185
|
def id(self) -> str:
|
|
181
|
-
if not self.user:
|
|
182
|
-
raise ValueError(f"Login {self.sn} has not complete yet")
|
|
183
186
|
return self.user.id
|
|
184
187
|
|
|
185
188
|
|
|
189
|
+
@dataclass
|
|
190
|
+
class LoginPartial(Login):
|
|
191
|
+
platform: Optional[str] = None
|
|
192
|
+
user: Optional[User] = None
|
|
193
|
+
|
|
194
|
+
|
|
186
195
|
@dataclass
|
|
187
196
|
class ArgvInteraction(ModelBase):
|
|
188
197
|
name: str
|
|
@@ -237,10 +246,10 @@ class Identify(ModelBase):
|
|
|
237
246
|
|
|
238
247
|
@dataclass
|
|
239
248
|
class Ready(ModelBase):
|
|
240
|
-
logins: list[
|
|
249
|
+
logins: list[LoginPartial]
|
|
241
250
|
proxy_urls: list[str] = field(default_factory=list)
|
|
242
251
|
|
|
243
|
-
__converter__ = {"logins": lambda raw: [
|
|
252
|
+
__converter__ = {"logins": lambda raw: [LoginPartial.parse(login) for login in raw]}
|
|
244
253
|
|
|
245
254
|
def dump(self):
|
|
246
255
|
return asdict(self)
|
|
@@ -260,10 +269,10 @@ class MetaPayload(ModelBase):
|
|
|
260
269
|
class Meta(ModelBase):
|
|
261
270
|
"""Meta 数据"""
|
|
262
271
|
|
|
263
|
-
logins: list[
|
|
272
|
+
logins: list[LoginPartial]
|
|
264
273
|
proxy_urls: list[str] = field(default_factory=list)
|
|
265
274
|
|
|
266
|
-
__converter__ = {"logins": lambda raw: [
|
|
275
|
+
__converter__ = {"logins": lambda raw: [LoginPartial.parse(login) for login in raw]}
|
|
267
276
|
|
|
268
277
|
def dump(self):
|
|
269
278
|
return asdict(self)
|
|
@@ -410,7 +419,7 @@ class Event(ModelBase):
|
|
|
410
419
|
raw["sn"] = raw["id"]
|
|
411
420
|
if "platform" in raw and "self_id" in raw and "login" not in raw:
|
|
412
421
|
raw["login"] = {
|
|
413
|
-
"sn":
|
|
422
|
+
"sn": 0,
|
|
414
423
|
"platform": raw["platform"],
|
|
415
424
|
"user": {"id": raw["self_id"]},
|
|
416
425
|
"status": LoginStatus.ONLINE,
|
|
@@ -497,6 +506,29 @@ class PageDequeResult(PageResult[T]):
|
|
|
497
506
|
return res
|
|
498
507
|
|
|
499
508
|
|
|
509
|
+
class IterablePageResult(Generic[T], AsyncIterable[T], Awaitable[PageResult[T]]):
|
|
510
|
+
def __init__(
|
|
511
|
+
self, func: Callable[[Optional[str]], Awaitable[PageResult[T]]], initial_page: Optional[str] = None
|
|
512
|
+
):
|
|
513
|
+
self.func = func
|
|
514
|
+
self.next_page = initial_page
|
|
515
|
+
|
|
516
|
+
def __await__(self):
|
|
517
|
+
return self.func(self.next_page).__await__()
|
|
518
|
+
|
|
519
|
+
def __aiter__(self):
|
|
520
|
+
async def _gen():
|
|
521
|
+
while True:
|
|
522
|
+
result = await self.func(self.next_page)
|
|
523
|
+
for item in result.data:
|
|
524
|
+
yield item
|
|
525
|
+
self.next_page = result.next
|
|
526
|
+
if not self.next_page:
|
|
527
|
+
break
|
|
528
|
+
|
|
529
|
+
return _gen()
|
|
530
|
+
|
|
531
|
+
|
|
500
532
|
Direction: TypeAlias = Literal["before", "after", "around"]
|
|
501
533
|
Order: TypeAlias = Literal["asc", "desc"]
|
|
502
534
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|