satori-python-core 0.16.2__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.2 → satori_python_core-0.16.3}/PKG-INFO +1 -1
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/pyproject.toml +1 -1
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/src/satori/__init__.py +1 -1
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/src/satori/event.py +2 -2
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/src/satori/model.py +39 -11
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/.mina/core.toml +0 -0
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/LICENSE +0 -0
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/README.md +0 -0
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/src/satori/const.py +0 -0
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/src/satori/element.py +0 -0
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/src/satori/exception.py +0 -0
- {satori_python_core-0.16.2 → satori_python_core-0.16.3}/src/satori/parser.py +0 -0
- {satori_python_core-0.16.2 → 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}
|
|
@@ -173,7 +174,7 @@ class Login(ModelBase):
|
|
|
173
174
|
if "self_id" in raw and "user" not in raw:
|
|
174
175
|
raw["user"] = {"id": raw["self_id"]}
|
|
175
176
|
if "sn" not in raw:
|
|
176
|
-
raw["sn"] =
|
|
177
|
+
raw["sn"] = 0
|
|
177
178
|
if "adapter" not in raw:
|
|
178
179
|
raw["adapter"] = "satori"
|
|
179
180
|
if "status" not in raw:
|
|
@@ -182,11 +183,15 @@ class Login(ModelBase):
|
|
|
182
183
|
|
|
183
184
|
@property
|
|
184
185
|
def id(self) -> str:
|
|
185
|
-
if not self.user:
|
|
186
|
-
raise ValueError(f"Login {self.sn} has not complete yet")
|
|
187
186
|
return self.user.id
|
|
188
187
|
|
|
189
188
|
|
|
189
|
+
@dataclass
|
|
190
|
+
class LoginPartial(Login):
|
|
191
|
+
platform: Optional[str] = None
|
|
192
|
+
user: Optional[User] = None
|
|
193
|
+
|
|
194
|
+
|
|
190
195
|
@dataclass
|
|
191
196
|
class ArgvInteraction(ModelBase):
|
|
192
197
|
name: str
|
|
@@ -241,10 +246,10 @@ class Identify(ModelBase):
|
|
|
241
246
|
|
|
242
247
|
@dataclass
|
|
243
248
|
class Ready(ModelBase):
|
|
244
|
-
logins: list[
|
|
249
|
+
logins: list[LoginPartial]
|
|
245
250
|
proxy_urls: list[str] = field(default_factory=list)
|
|
246
251
|
|
|
247
|
-
__converter__ = {"logins": lambda raw: [
|
|
252
|
+
__converter__ = {"logins": lambda raw: [LoginPartial.parse(login) for login in raw]}
|
|
248
253
|
|
|
249
254
|
def dump(self):
|
|
250
255
|
return asdict(self)
|
|
@@ -264,10 +269,10 @@ class MetaPayload(ModelBase):
|
|
|
264
269
|
class Meta(ModelBase):
|
|
265
270
|
"""Meta 数据"""
|
|
266
271
|
|
|
267
|
-
logins: list[
|
|
272
|
+
logins: list[LoginPartial]
|
|
268
273
|
proxy_urls: list[str] = field(default_factory=list)
|
|
269
274
|
|
|
270
|
-
__converter__ = {"logins": lambda raw: [
|
|
275
|
+
__converter__ = {"logins": lambda raw: [LoginPartial.parse(login) for login in raw]}
|
|
271
276
|
|
|
272
277
|
def dump(self):
|
|
273
278
|
return asdict(self)
|
|
@@ -414,7 +419,7 @@ class Event(ModelBase):
|
|
|
414
419
|
raw["sn"] = raw["id"]
|
|
415
420
|
if "platform" in raw and "self_id" in raw and "login" not in raw:
|
|
416
421
|
raw["login"] = {
|
|
417
|
-
"sn":
|
|
422
|
+
"sn": 0,
|
|
418
423
|
"platform": raw["platform"],
|
|
419
424
|
"user": {"id": raw["self_id"]},
|
|
420
425
|
"status": LoginStatus.ONLINE,
|
|
@@ -501,6 +506,29 @@ class PageDequeResult(PageResult[T]):
|
|
|
501
506
|
return res
|
|
502
507
|
|
|
503
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
|
+
|
|
504
532
|
Direction: TypeAlias = Literal["before", "after", "around"]
|
|
505
533
|
Order: TypeAlias = Literal["asc", "desc"]
|
|
506
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
|