attenpy 0.3.0__tar.gz → 0.4.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.
- {attenpy-0.3.0 → attenpy-0.4.0}/PKG-INFO +1 -1
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/__init__.py +17 -1
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/client.py +12 -1
- attenpy-0.4.0/attenpy/endpoints/__init__.py +17 -0
- attenpy-0.4.0/attenpy/endpoints/chats.py +83 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/endpoints/explores.py +3 -34
- attenpy-0.4.0/attenpy/endpoints/me.py +90 -0
- attenpy-0.4.0/attenpy/endpoints/messages.py +21 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/endpoints/users.py +10 -40
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/http.py +6 -2
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/models/__init__.py +15 -2
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/models/attachment.py +1 -1
- attenpy-0.4.0/attenpy/models/bot.py +16 -0
- attenpy-0.4.0/attenpy/models/chat.py +73 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/models/notice.py +1 -1
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/models/post.py +1 -1
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/models/user.py +8 -1
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/payloads/__init__.py +2 -2
- attenpy-0.4.0/attenpy/payloads/chat.py +5 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/snowflake.py +1 -5
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/ws.py +4 -15
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy.egg-info/PKG-INFO +1 -1
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy.egg-info/SOURCES.txt +7 -2
- attenpy-0.4.0/pyproject.toml +41 -0
- attenpy-0.3.0/attenpy/endpoints/__init__.py +0 -6
- attenpy-0.3.0/attenpy/payloads/ws.py +0 -7
- attenpy-0.3.0/pyproject.toml +0 -72
- {attenpy-0.3.0 → attenpy-0.4.0}/LICENSE +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/README.md +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/endpoints/notices.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/endpoints/posts.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/exceptions.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/models/base.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/pagination.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/payloads/explore.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/payloads/notice.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/payloads/post.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/payloads/user.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/ref.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/types.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy/utils.py +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy.egg-info/dependency_links.txt +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy.egg-info/requires.txt +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/attenpy.egg-info/top_level.txt +0 -0
- {attenpy-0.3.0 → attenpy-0.4.0}/setup.cfg +0 -0
|
@@ -3,28 +3,42 @@ from .exceptions import AttenpyException, HTTPException, InvalidResponseError
|
|
|
3
3
|
from .models import (
|
|
4
4
|
Attachment,
|
|
5
5
|
AttachmentCategory,
|
|
6
|
+
Bot,
|
|
7
|
+
ChatChannel,
|
|
8
|
+
ChatMember,
|
|
9
|
+
ChatMessage,
|
|
10
|
+
ChatMessageType,
|
|
6
11
|
Notice,
|
|
7
12
|
NoticeKind,
|
|
8
13
|
NoticeTarget,
|
|
9
14
|
NoticeType,
|
|
10
15
|
PartialAttachment,
|
|
16
|
+
PartialChatMessage,
|
|
11
17
|
PartialPost,
|
|
12
18
|
PartialUser,
|
|
13
19
|
Post,
|
|
14
20
|
User,
|
|
21
|
+
UserAccessStatus,
|
|
15
22
|
)
|
|
16
23
|
from .payloads import (
|
|
24
|
+
ChatUnreadCountPayload,
|
|
17
25
|
NoticeUnreadCountPayload,
|
|
18
26
|
ParentsPostPayload,
|
|
19
27
|
)
|
|
20
28
|
from .ref import UserRef
|
|
21
29
|
from .snowflake import Snowflake
|
|
22
30
|
|
|
23
|
-
__version__ = "0.
|
|
31
|
+
__version__ = "0.4.0"
|
|
24
32
|
__all__ = [
|
|
25
33
|
"AttenpyException",
|
|
26
34
|
"Attachment",
|
|
27
35
|
"AttachmentCategory",
|
|
36
|
+
"Bot",
|
|
37
|
+
"ChatChannel",
|
|
38
|
+
"ChatMember",
|
|
39
|
+
"ChatMessage",
|
|
40
|
+
"ChatMessageType",
|
|
41
|
+
"ChatUnreadCountPayload",
|
|
28
42
|
"Client",
|
|
29
43
|
"HTTPException",
|
|
30
44
|
"InvalidResponseError",
|
|
@@ -35,11 +49,13 @@ __all__ = [
|
|
|
35
49
|
"NoticeUnreadCountPayload",
|
|
36
50
|
"ParentsPostPayload",
|
|
37
51
|
"PartialAttachment",
|
|
52
|
+
"PartialChatMessage",
|
|
38
53
|
"PartialPost",
|
|
39
54
|
"PartialUser",
|
|
40
55
|
"Post",
|
|
41
56
|
"Snowflake",
|
|
42
57
|
"User",
|
|
58
|
+
"UserAccessStatus",
|
|
43
59
|
"UserRef",
|
|
44
60
|
"__version__",
|
|
45
61
|
]
|
|
@@ -2,7 +2,15 @@ import asyncio
|
|
|
2
2
|
from collections.abc import Callable
|
|
3
3
|
from types import TracebackType
|
|
4
4
|
|
|
5
|
-
from .endpoints import
|
|
5
|
+
from .endpoints import (
|
|
6
|
+
ChatEndpoint,
|
|
7
|
+
ExploreEndpoint,
|
|
8
|
+
MeEndpoint,
|
|
9
|
+
MessageEndpoint,
|
|
10
|
+
NoticeEndpoint,
|
|
11
|
+
PostEndpoint,
|
|
12
|
+
UserEndpoint,
|
|
13
|
+
)
|
|
6
14
|
from .http import HTTPClient
|
|
7
15
|
from .ws import EventHandler, WSClient
|
|
8
16
|
|
|
@@ -29,9 +37,12 @@ class Client:
|
|
|
29
37
|
self.ws = WSClient(self)
|
|
30
38
|
|
|
31
39
|
self.users = UserEndpoint(self)
|
|
40
|
+
self.me = MeEndpoint(self)
|
|
32
41
|
self.posts = PostEndpoint(self)
|
|
33
42
|
self.notices = NoticeEndpoint(self)
|
|
34
43
|
self.explores = ExploreEndpoint(self)
|
|
44
|
+
self.chats = ChatEndpoint(self)
|
|
45
|
+
self.messages = MessageEndpoint(self)
|
|
35
46
|
|
|
36
47
|
self._closed_event = asyncio.Event()
|
|
37
48
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .chats import ChatEndpoint
|
|
2
|
+
from .explores import ExploreEndpoint
|
|
3
|
+
from .me import MeEndpoint
|
|
4
|
+
from .messages import MessageEndpoint
|
|
5
|
+
from .notices import NoticeEndpoint
|
|
6
|
+
from .posts import PostEndpoint
|
|
7
|
+
from .users import UserEndpoint
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"UserEndpoint",
|
|
11
|
+
"MeEndpoint",
|
|
12
|
+
"PostEndpoint",
|
|
13
|
+
"NoticeEndpoint",
|
|
14
|
+
"ExploreEndpoint",
|
|
15
|
+
"ChatEndpoint",
|
|
16
|
+
"MessageEndpoint",
|
|
17
|
+
]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from collections.abc import AsyncGenerator, Sequence
|
|
2
|
+
from typing import TYPE_CHECKING, Unpack
|
|
3
|
+
|
|
4
|
+
from ..models import Attachment, ChatChannel, ChatMember, ChatMessage, PartialChatMessage
|
|
5
|
+
from ..pagination import PaginateOptions, paginate
|
|
6
|
+
from ..payloads import ChatUnreadCountPayload
|
|
7
|
+
from ..ref import UserRef
|
|
8
|
+
from ..utils import int_or_none
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from ..client import Client
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ChatEndpoint:
|
|
15
|
+
def __init__(self, client: "Client"):
|
|
16
|
+
self.client = client
|
|
17
|
+
|
|
18
|
+
async def list(self, **kw: Unpack[PaginateOptions]) -> AsyncGenerator[ChatChannel]:
|
|
19
|
+
async for data in paginate(self.client.http, "/chats", **kw):
|
|
20
|
+
yield ChatChannel.model_validate(data)
|
|
21
|
+
|
|
22
|
+
async def get_unread_count(self) -> ChatUnreadCountPayload:
|
|
23
|
+
return ChatUnreadCountPayload.model_validate(
|
|
24
|
+
(await self.client.http.get("/chats/unread-count")).data
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
async def get(self, channel: int | ChatChannel) -> ChatChannel:
|
|
28
|
+
return ChatChannel.model_validate(
|
|
29
|
+
(await self.client.http.get(f"/chats/{int(channel)}")).data
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
async def get_members(
|
|
33
|
+
self, channel: int | ChatChannel, **kw: Unpack[PaginateOptions]
|
|
34
|
+
) -> AsyncGenerator[ChatMember]:
|
|
35
|
+
async for data in paginate(self.client.http, f"/chats/{int(channel)}/members", **kw):
|
|
36
|
+
yield ChatMember.model_validate(data)
|
|
37
|
+
|
|
38
|
+
async def get_member(self, channel: int | ChatChannel, user: UserRef | str) -> ChatMember:
|
|
39
|
+
return ChatMember.model_validate(
|
|
40
|
+
(await self.client.http.get(f"/chats/{int(channel)}/members/{user}")).data
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
async def join(self, channel: int | ChatChannel) -> ChatChannel:
|
|
44
|
+
return ChatChannel.model_validate(
|
|
45
|
+
(
|
|
46
|
+
await self.client.http.patch(
|
|
47
|
+
f"/chats/{int(channel)}/members/{UserRef.ME}", json={"is_joined": True}
|
|
48
|
+
)
|
|
49
|
+
).data
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
async def remove_member(self, channel: int | ChatChannel, user: UserRef | str):
|
|
53
|
+
await self.client.http.delete(f"/chats/{int(channel)}/members/{user}")
|
|
54
|
+
|
|
55
|
+
async def mark_read(self, channel: int | ChatChannel):
|
|
56
|
+
await self.client.http.post(f"/chats/{int(channel)}/read")
|
|
57
|
+
|
|
58
|
+
async def create_message(
|
|
59
|
+
self,
|
|
60
|
+
channel: int | ChatChannel,
|
|
61
|
+
content: str = "",
|
|
62
|
+
*,
|
|
63
|
+
attachments: Sequence[int | Attachment] | None = None,
|
|
64
|
+
reply: int | PartialChatMessage | None = None,
|
|
65
|
+
) -> ChatMessage:
|
|
66
|
+
return ChatMessage.model_validate(
|
|
67
|
+
(
|
|
68
|
+
await self.client.http.post(
|
|
69
|
+
f"/chats/{int(channel)}/messages",
|
|
70
|
+
json={
|
|
71
|
+
"content": content,
|
|
72
|
+
"attachment_ids": [int(attachment) for attachment in attachments or []],
|
|
73
|
+
"reply_id": int_or_none(reply),
|
|
74
|
+
},
|
|
75
|
+
)
|
|
76
|
+
).data
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
async def get_messages(
|
|
80
|
+
self, channel: int | ChatChannel, **kw: Unpack[PaginateOptions]
|
|
81
|
+
) -> AsyncGenerator[ChatMessage]:
|
|
82
|
+
async for data in paginate(self.client.http, f"/chats/{int(channel)}/messages", **kw):
|
|
83
|
+
yield ChatMessage.model_validate(data)
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
from collections.abc import AsyncGenerator
|
|
2
|
-
from datetime import datetime
|
|
1
|
+
from collections.abc import AsyncGenerator
|
|
3
2
|
from typing import TYPE_CHECKING, Unpack
|
|
4
3
|
|
|
5
4
|
from pydantic import TypeAdapter
|
|
6
5
|
|
|
7
|
-
from ..models import Post
|
|
8
|
-
from ..pagination import
|
|
9
|
-
PaginateOptions,
|
|
10
|
-
paginate,
|
|
11
|
-
)
|
|
6
|
+
from ..models import Post
|
|
7
|
+
from ..pagination import PaginateOptions, paginate
|
|
12
8
|
from ..payloads import StatPayload, TrendPayload
|
|
13
|
-
from ..ref import UserRef
|
|
14
|
-
from ..utils import api_bool
|
|
15
9
|
|
|
16
10
|
if TYPE_CHECKING:
|
|
17
11
|
from ..client import Client
|
|
@@ -43,31 +37,6 @@ class ExploreEndpoint:
|
|
|
43
37
|
):
|
|
44
38
|
yield data
|
|
45
39
|
|
|
46
|
-
async def search_post(
|
|
47
|
-
self,
|
|
48
|
-
q: str,
|
|
49
|
-
*,
|
|
50
|
-
user: Sequence[UserRef | str] | None = None,
|
|
51
|
-
visibility: PostVisibility | None = None,
|
|
52
|
-
is_reply: bool | None = None,
|
|
53
|
-
before: datetime | str | None = None,
|
|
54
|
-
after: datetime | str | None = None,
|
|
55
|
-
**kw: Unpack[PaginateOptions],
|
|
56
|
-
) -> AsyncGenerator[Post]:
|
|
57
|
-
params = dict[str, str | list[str]](q=q)
|
|
58
|
-
if user:
|
|
59
|
-
params["user"] = list(map(str, user))
|
|
60
|
-
if visibility:
|
|
61
|
-
params["visibility"] = str(visibility)
|
|
62
|
-
if is_reply is not None:
|
|
63
|
-
params["is_reply"] = api_bool(is_reply)
|
|
64
|
-
if before:
|
|
65
|
-
params["before"] = before.isoformat() if isinstance(before, datetime) else str(before)
|
|
66
|
-
if after:
|
|
67
|
-
params["after"] = after.isoformat() if isinstance(after, datetime) else str(after)
|
|
68
|
-
async for data in paginate(self.client.http, "/explore/search", params=params, **kw):
|
|
69
|
-
yield Post.model_validate(data)
|
|
70
|
-
|
|
71
40
|
async def get_stats(self) -> AsyncGenerator[StatPayload]:
|
|
72
41
|
for data in STAT_DATA_TA.validate_python((await self.client.http.get("/stats")).data):
|
|
73
42
|
yield data
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from collections.abc import AsyncGenerator
|
|
2
|
+
from types import EllipsisType
|
|
3
|
+
from typing import TYPE_CHECKING, Unpack
|
|
4
|
+
|
|
5
|
+
from ..models import (
|
|
6
|
+
Attachment,
|
|
7
|
+
Bot,
|
|
8
|
+
PartialPost,
|
|
9
|
+
PartialUser,
|
|
10
|
+
Post,
|
|
11
|
+
User,
|
|
12
|
+
UserAccessStatus,
|
|
13
|
+
)
|
|
14
|
+
from ..pagination import PaginateOptions, paginate
|
|
15
|
+
from ..ref import UserRef
|
|
16
|
+
from ..utils import int_or_none
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from ..client import Client
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MeEndpoint:
|
|
23
|
+
def __init__(self, client: "Client"):
|
|
24
|
+
self.client = client
|
|
25
|
+
|
|
26
|
+
async def edit(
|
|
27
|
+
self,
|
|
28
|
+
*,
|
|
29
|
+
display_name: str | None | EllipsisType = ...,
|
|
30
|
+
bio: str | EllipsisType = ...,
|
|
31
|
+
icon: int | Attachment | None | EllipsisType = ...,
|
|
32
|
+
banner: int | Attachment | None | EllipsisType = ...,
|
|
33
|
+
pinned: int | PartialPost | None | EllipsisType = ...,
|
|
34
|
+
) -> User:
|
|
35
|
+
payload = {}
|
|
36
|
+
if display_name is not ...:
|
|
37
|
+
payload["display_name"] = display_name
|
|
38
|
+
if bio is not ...:
|
|
39
|
+
payload["bio"] = bio
|
|
40
|
+
if icon is not ...:
|
|
41
|
+
payload["icon_id"] = int_or_none(icon)
|
|
42
|
+
if banner is not ...:
|
|
43
|
+
payload["banner_id"] = int_or_none(banner)
|
|
44
|
+
if pinned is not ...:
|
|
45
|
+
payload["pinned_id"] = int_or_none(pinned)
|
|
46
|
+
return User.model_validate(
|
|
47
|
+
(await self.client.http.patch(f"/users/{UserRef.ME}", json=payload)).data
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
async def get_mutes(self, **kw: Unpack[PaginateOptions]) -> AsyncGenerator[PartialUser]:
|
|
51
|
+
async for data in paginate(self.client.http, f"/users/{UserRef.ME}/mutes", **kw):
|
|
52
|
+
yield PartialUser.model_validate(data)
|
|
53
|
+
|
|
54
|
+
async def get_bookmarks(self, **kw: Unpack[PaginateOptions]) -> AsyncGenerator[Post]:
|
|
55
|
+
async for data in paginate(self.client.http, f"/users/{UserRef.ME}/bookmarks", **kw):
|
|
56
|
+
yield Post.model_validate(data)
|
|
57
|
+
|
|
58
|
+
async def get_accesses(self, **kw: Unpack[PaginateOptions]) -> AsyncGenerator[PartialUser]:
|
|
59
|
+
async for data in paginate(self.client.http, f"/users/{UserRef.ME}/accesses", **kw):
|
|
60
|
+
yield PartialUser.model_validate(data)
|
|
61
|
+
|
|
62
|
+
async def get_viewers(
|
|
63
|
+
self,
|
|
64
|
+
*,
|
|
65
|
+
status: UserAccessStatus,
|
|
66
|
+
**kw: Unpack[PaginateOptions],
|
|
67
|
+
) -> AsyncGenerator[PartialUser]:
|
|
68
|
+
async for data in paginate(
|
|
69
|
+
self.client.http,
|
|
70
|
+
f"/users/{UserRef.ME}/viewers",
|
|
71
|
+
params={"status": status.value},
|
|
72
|
+
**kw,
|
|
73
|
+
):
|
|
74
|
+
yield PartialUser.model_validate(data)
|
|
75
|
+
|
|
76
|
+
async def accept_viewer(self, viewer: UserRef | str):
|
|
77
|
+
await self.client.http.post(f"/users/{UserRef.ME}/viewers/{viewer}/accept")
|
|
78
|
+
|
|
79
|
+
async def decline_viewer(self, viewer: UserRef | str):
|
|
80
|
+
await self.client.http.post(f"/users/{UserRef.ME}/viewers/{viewer}/decline")
|
|
81
|
+
|
|
82
|
+
async def remove_viewer(self, viewer: UserRef | str):
|
|
83
|
+
await self.client.http.delete(f"/users/{UserRef.ME}/viewers/{viewer}")
|
|
84
|
+
|
|
85
|
+
async def get_bot(self) -> Bot | None:
|
|
86
|
+
data = (await self.client.http.get(f"/users/{UserRef.ME}/bot")).data
|
|
87
|
+
return Bot.model_validate(data) if data is not None else None
|
|
88
|
+
|
|
89
|
+
async def revoke_bot(self):
|
|
90
|
+
await self.client.http.delete(f"/users/{UserRef.ME}/bot")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING
|
|
2
|
+
|
|
3
|
+
from ..models import ChatMessage
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from ..client import Client
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MessageEndpoint:
|
|
10
|
+
def __init__(self, client: "Client"):
|
|
11
|
+
self.client = client
|
|
12
|
+
|
|
13
|
+
async def get(self, message: int | ChatMessage) -> ChatMessage:
|
|
14
|
+
return ChatMessage.model_validate(
|
|
15
|
+
(await self.client.http.get(f"/messages/{int(message)}")).data
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
async def delete(self, message: int | ChatMessage) -> ChatMessage:
|
|
19
|
+
return ChatMessage.model_validate(
|
|
20
|
+
(await self.client.http.delete(f"/messages/{int(message)}")).data
|
|
21
|
+
)
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
from collections.abc import AsyncGenerator
|
|
2
|
-
from types import EllipsisType
|
|
3
2
|
from typing import TYPE_CHECKING, Unpack
|
|
4
3
|
|
|
5
4
|
from attenpy.payloads import BanStatusPayload
|
|
6
5
|
|
|
7
|
-
from ..models import
|
|
6
|
+
from ..models import ChatChannel, PartialUser, Post, User
|
|
8
7
|
from ..pagination import (
|
|
9
8
|
PaginateOptions,
|
|
10
9
|
paginate,
|
|
11
10
|
)
|
|
12
11
|
from ..ref import UserRef
|
|
13
|
-
from ..utils import int_or_none
|
|
14
12
|
|
|
15
13
|
if TYPE_CHECKING:
|
|
16
14
|
from ..client import Client
|
|
@@ -23,31 +21,6 @@ class UserEndpoint:
|
|
|
23
21
|
async def get(self, user: UserRef | str) -> User:
|
|
24
22
|
return User.model_validate((await self.client.http.get(f"/users/{user}")).data)
|
|
25
23
|
|
|
26
|
-
async def edit(
|
|
27
|
-
self,
|
|
28
|
-
user: UserRef | str,
|
|
29
|
-
*,
|
|
30
|
-
display_name: str | None | EllipsisType = ...,
|
|
31
|
-
bio: str | EllipsisType = ...,
|
|
32
|
-
icon: int | Attachment | None | EllipsisType = ...,
|
|
33
|
-
banner: int | Attachment | None | EllipsisType = ...,
|
|
34
|
-
pinned: int | PartialPost | None | EllipsisType = ...,
|
|
35
|
-
) -> User:
|
|
36
|
-
payload = {}
|
|
37
|
-
if display_name is not ...:
|
|
38
|
-
payload["display_name"] = display_name
|
|
39
|
-
if bio is not ...:
|
|
40
|
-
payload["bio"] = bio
|
|
41
|
-
if icon is not ...:
|
|
42
|
-
payload["icon_id"] = int_or_none(icon)
|
|
43
|
-
if banner is not ...:
|
|
44
|
-
payload["banner_id"] = int_or_none(banner)
|
|
45
|
-
if pinned is not ...:
|
|
46
|
-
payload["pinned_id"] = int_or_none(pinned)
|
|
47
|
-
return User.model_validate(
|
|
48
|
-
(await self.client.http.patch(f"/users/{user}", json=payload)).data
|
|
49
|
-
)
|
|
50
|
-
|
|
51
24
|
async def follow(self, user: UserRef | str):
|
|
52
25
|
await self.client.http.post(f"/users/{user}/follow")
|
|
53
26
|
|
|
@@ -72,12 +45,6 @@ class UserEndpoint:
|
|
|
72
45
|
async for data in paginate(self.client.http, f"/users/{user}/following", **kw):
|
|
73
46
|
yield PartialUser.model_validate(data)
|
|
74
47
|
|
|
75
|
-
async def get_mutes(
|
|
76
|
-
self, user: UserRef | str, **kw: Unpack[PaginateOptions]
|
|
77
|
-
) -> AsyncGenerator[PartialUser]:
|
|
78
|
-
async for data in paginate(self.client.http, f"/users/{user}/mutes", **kw):
|
|
79
|
-
yield PartialUser.model_validate(data)
|
|
80
|
-
|
|
81
48
|
async def get_posts(
|
|
82
49
|
self, user: UserRef | str, **kw: Unpack[PaginateOptions]
|
|
83
50
|
) -> AsyncGenerator[Post]:
|
|
@@ -96,12 +63,6 @@ class UserEndpoint:
|
|
|
96
63
|
async for data in paginate(self.client.http, f"/users/{user}/loves", **kw):
|
|
97
64
|
yield Post.model_validate(data)
|
|
98
65
|
|
|
99
|
-
async def get_bookmarks(
|
|
100
|
-
self, user: UserRef | str, **kw: Unpack[PaginateOptions]
|
|
101
|
-
) -> AsyncGenerator[Post]:
|
|
102
|
-
async for data in paginate(self.client.http, f"/users/{user}/bookmarks", **kw):
|
|
103
|
-
yield Post.model_validate(data)
|
|
104
|
-
|
|
105
66
|
async def get_reposts(
|
|
106
67
|
self, user: UserRef | str, **kw: Unpack[PaginateOptions]
|
|
107
68
|
) -> AsyncGenerator[Post]:
|
|
@@ -112,3 +73,12 @@ class UserEndpoint:
|
|
|
112
73
|
return BanStatusPayload.model_validate(
|
|
113
74
|
(await self.client.http.get(f"/users/{user}/ban")).data
|
|
114
75
|
)
|
|
76
|
+
|
|
77
|
+
async def request_access(self, user: UserRef | str):
|
|
78
|
+
await self.client.http.post(f"/users/{user}/access")
|
|
79
|
+
|
|
80
|
+
async def remove_access(self, user: UserRef | str):
|
|
81
|
+
await self.client.http.delete(f"/users/{user}/access")
|
|
82
|
+
|
|
83
|
+
async def get_chat(self, user: UserRef | str) -> ChatChannel:
|
|
84
|
+
return ChatChannel.model_validate((await self.client.http.get(f"/users/{user}/chat")).data)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
from types import TracebackType
|
|
3
|
-
from typing import Any, TypedDict, Unpack
|
|
3
|
+
from typing import Any, TypedDict, Unpack
|
|
4
4
|
|
|
5
5
|
import aiohttp
|
|
6
6
|
from pydantic import ValidationError
|
|
@@ -71,10 +71,14 @@ class HTTPClient:
|
|
|
71
71
|
async def get(self, path: str, **kw: Unpack[RequestOptions]) -> SuccessResponse[Any]:
|
|
72
72
|
return await self._request("GET", path, **kw)
|
|
73
73
|
|
|
74
|
+
async def ws_connect(self, url: str) -> aiohttp.ClientWebSocketResponse:
|
|
75
|
+
session = await self._get_session()
|
|
76
|
+
return await session.ws_connect(url)
|
|
77
|
+
|
|
74
78
|
async def get_list(self, path: str, **kw: Unpack[RequestOptions]) -> ListResponse[Any]:
|
|
75
79
|
data = await self._request("GET", path, **kw)
|
|
76
80
|
if isinstance(data, ListResponse):
|
|
77
|
-
return
|
|
81
|
+
return data
|
|
78
82
|
raise InvalidResponseError(data.model_dump(mode="python"))
|
|
79
83
|
|
|
80
84
|
async def post(self, path: str, **kw: Unpack[RequestOptions]) -> SuccessResponse[Any]:
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
from .attachment import Attachment, AttachmentCategory, PartialAttachment
|
|
2
2
|
from .base import CursorPage, ErrorResponse, ListResponse, SuccessResponse
|
|
3
|
+
from .bot import Bot
|
|
4
|
+
from .chat import ChatChannel, ChatMember, ChatMessage, ChatMessageType, PartialChatMessage
|
|
3
5
|
from .notice import Notice, NoticeKind, NoticeTarget, NoticeType, Warn
|
|
4
6
|
from .post import PartialPost, Post, PostVisibility
|
|
5
|
-
from .user import PartialUser, User
|
|
7
|
+
from .user import PartialUser, User, UserAccessStatus
|
|
6
8
|
|
|
9
|
+
ChatChannel.model_rebuild()
|
|
10
|
+
ChatMember.model_rebuild()
|
|
11
|
+
ChatMessage.model_rebuild()
|
|
7
12
|
Notice.model_rebuild()
|
|
13
|
+
PartialChatMessage.model_rebuild()
|
|
8
14
|
PartialPost.model_rebuild()
|
|
9
15
|
Post.model_rebuild()
|
|
10
16
|
PartialUser.model_rebuild()
|
|
@@ -13,10 +19,16 @@ User.model_rebuild()
|
|
|
13
19
|
__all__ = [
|
|
14
20
|
"Attachment",
|
|
15
21
|
"AttachmentCategory",
|
|
22
|
+
"Bot",
|
|
23
|
+
"ChatChannel",
|
|
24
|
+
"ChatMember",
|
|
25
|
+
"ChatMessage",
|
|
26
|
+
"ChatMessageType",
|
|
16
27
|
"CursorPage",
|
|
17
28
|
"ErrorResponse",
|
|
18
|
-
"PartialAttachment",
|
|
19
29
|
"ListResponse",
|
|
30
|
+
"PartialAttachment",
|
|
31
|
+
"PartialChatMessage",
|
|
20
32
|
"Notice",
|
|
21
33
|
"NoticeKind",
|
|
22
34
|
"NoticeTarget",
|
|
@@ -26,6 +38,7 @@ __all__ = [
|
|
|
26
38
|
"Post",
|
|
27
39
|
"SuccessResponse",
|
|
28
40
|
"User",
|
|
41
|
+
"UserAccessStatus",
|
|
29
42
|
"PostVisibility",
|
|
30
43
|
"Warn",
|
|
31
44
|
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Bot(BaseModel):
|
|
7
|
+
id: int
|
|
8
|
+
owner_user_id: int
|
|
9
|
+
name: str
|
|
10
|
+
generation: int
|
|
11
|
+
created_at: datetime
|
|
12
|
+
revoked_at: datetime | None
|
|
13
|
+
is_revoked: bool
|
|
14
|
+
|
|
15
|
+
def __int__(self) -> int:
|
|
16
|
+
return self.id
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from enum import StrEnum, auto
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
|
|
7
|
+
from ..snowflake import Snowflake
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from .attachment import Attachment
|
|
11
|
+
from .user import PartialUser
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ChatMessageType(StrEnum):
|
|
15
|
+
MESSAGE = auto()
|
|
16
|
+
INVITED = auto()
|
|
17
|
+
JOINED = auto()
|
|
18
|
+
LEFT = auto()
|
|
19
|
+
KICKED = auto()
|
|
20
|
+
TRANSFERRED = auto()
|
|
21
|
+
DELETED = auto()
|
|
22
|
+
WARN = auto()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class PartialChatMessage(BaseModel):
|
|
26
|
+
id: int
|
|
27
|
+
channel_id: int
|
|
28
|
+
type: ChatMessageType
|
|
29
|
+
content: str
|
|
30
|
+
edited_at: datetime | None
|
|
31
|
+
author: "PartialUser"
|
|
32
|
+
attachments: list["Attachment"]
|
|
33
|
+
|
|
34
|
+
def __int__(self) -> int:
|
|
35
|
+
return self.id
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def created_at(self) -> datetime:
|
|
39
|
+
return Snowflake(self.id).created_at
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ChatMessage(PartialChatMessage):
|
|
43
|
+
target_message: PartialChatMessage | None
|
|
44
|
+
target_user: "PartialUser | None"
|
|
45
|
+
is_read: bool
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ChatChannel(BaseModel):
|
|
49
|
+
id: int
|
|
50
|
+
title: str
|
|
51
|
+
is_group: bool
|
|
52
|
+
everyone_can_invite: bool
|
|
53
|
+
member_count: int
|
|
54
|
+
owner_id: int | None
|
|
55
|
+
icon: "Attachment | None"
|
|
56
|
+
is_joined: bool
|
|
57
|
+
read_message_id: int
|
|
58
|
+
unread_message_count: int
|
|
59
|
+
newest_message: PartialChatMessage | None
|
|
60
|
+
partner: "PartialUser | None"
|
|
61
|
+
|
|
62
|
+
def __int__(self) -> int:
|
|
63
|
+
return self.id
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def created_at(self) -> datetime:
|
|
67
|
+
return Snowflake(self.id).created_at
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class ChatMember(BaseModel):
|
|
71
|
+
user: "PartialUser"
|
|
72
|
+
is_joined: bool
|
|
73
|
+
is_owner: bool
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
|
+
from enum import StrEnum, auto
|
|
2
3
|
from typing import TYPE_CHECKING
|
|
3
4
|
|
|
4
5
|
from pydantic import BaseModel
|
|
@@ -11,6 +12,12 @@ if TYPE_CHECKING:
|
|
|
11
12
|
from .post import Post
|
|
12
13
|
|
|
13
14
|
|
|
15
|
+
class UserAccessStatus(StrEnum):
|
|
16
|
+
PENDING = auto()
|
|
17
|
+
ACCEPTED = auto()
|
|
18
|
+
DECLINED = auto()
|
|
19
|
+
|
|
20
|
+
|
|
14
21
|
class PartialUser(BaseModel):
|
|
15
22
|
id: int
|
|
16
23
|
scratch_name: str
|
|
@@ -32,7 +39,7 @@ class PartialUser(BaseModel):
|
|
|
32
39
|
|
|
33
40
|
@property
|
|
34
41
|
def created_at(self) -> datetime:
|
|
35
|
-
return Snowflake(self.id).
|
|
42
|
+
return Snowflake(self.id).created_at
|
|
36
43
|
|
|
37
44
|
|
|
38
45
|
class User(PartialUser):
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
from .chat import ChatUnreadCountPayload
|
|
1
2
|
from .explore import StatPayload, TrendPayload
|
|
2
3
|
from .notice import NoticeUnreadCountPayload
|
|
3
4
|
from .post import ParentsPostPayload
|
|
4
5
|
from .user import BanStatusPayload
|
|
5
|
-
from .ws import WsTokenPayload
|
|
6
6
|
|
|
7
7
|
__all__ = [
|
|
8
8
|
"ParentsPostPayload",
|
|
9
9
|
"NoticeUnreadCountPayload",
|
|
10
|
-
"
|
|
10
|
+
"ChatUnreadCountPayload",
|
|
11
11
|
"TrendPayload",
|
|
12
12
|
"StatPayload",
|
|
13
13
|
"BanStatusPayload",
|
|
@@ -61,13 +61,9 @@ class Snowflake:
|
|
|
61
61
|
def timestamp_ms(self) -> int:
|
|
62
62
|
return (self.value >> TIMESTAMP_SHIFT) + EPOCH_MS
|
|
63
63
|
|
|
64
|
-
@property
|
|
65
|
-
def datetime(self) -> datetime:
|
|
66
|
-
return datetime.fromtimestamp(self.timestamp_ms / 1000, tz=UTC)
|
|
67
|
-
|
|
68
64
|
@property
|
|
69
65
|
def created_at(self) -> datetime:
|
|
70
|
-
return self.
|
|
66
|
+
return datetime.fromtimestamp(self.timestamp_ms / 1000, tz=UTC)
|
|
71
67
|
|
|
72
68
|
@property
|
|
73
69
|
def worker_id(self) -> int:
|
|
@@ -5,14 +5,12 @@ from collections.abc import Callable, Coroutine
|
|
|
5
5
|
from contextlib import suppress
|
|
6
6
|
from json import JSONDecodeError
|
|
7
7
|
from typing import TYPE_CHECKING, Any, cast
|
|
8
|
-
from urllib.parse import
|
|
8
|
+
from urllib.parse import urlsplit, urlunsplit
|
|
9
9
|
|
|
10
10
|
import aiohttp
|
|
11
11
|
from pydantic import BaseModel
|
|
12
12
|
|
|
13
13
|
from .models import Notice
|
|
14
|
-
from .payloads import WsTokenPayload
|
|
15
|
-
from .ref import UserRef
|
|
16
14
|
|
|
17
15
|
if TYPE_CHECKING:
|
|
18
16
|
from .client import Client
|
|
@@ -102,10 +100,7 @@ class WSClient:
|
|
|
102
100
|
await asyncio.sleep(1)
|
|
103
101
|
|
|
104
102
|
async def _run_once(self) -> None:
|
|
105
|
-
|
|
106
|
-
session = await self.client.http._get_session()
|
|
107
|
-
|
|
108
|
-
async with session.ws_connect(self._build_ws_url(token)) as ws:
|
|
103
|
+
async with await self.client.http.ws_connect(self._build_ws_url()) as ws:
|
|
109
104
|
self._ws = ws
|
|
110
105
|
try:
|
|
111
106
|
async for message in ws:
|
|
@@ -136,16 +131,10 @@ class WSClient:
|
|
|
136
131
|
finally:
|
|
137
132
|
self._ws = None
|
|
138
133
|
|
|
139
|
-
|
|
140
|
-
response = await self.client.http.post(f"/users/{UserRef.ME}/bot/ws-token")
|
|
141
|
-
payload = WsTokenPayload.model_validate(response.data)
|
|
142
|
-
return payload.token
|
|
143
|
-
|
|
144
|
-
def _build_ws_url(self, token: str) -> str:
|
|
134
|
+
def _build_ws_url(self) -> str:
|
|
145
135
|
parsed = urlsplit(self.client.base_url)
|
|
146
136
|
scheme = "wss" if parsed.scheme == "https" else "ws"
|
|
147
|
-
|
|
148
|
-
return urlunsplit((scheme, parsed.netloc, "/ws", query, ""))
|
|
137
|
+
return urlunsplit((scheme, parsed.netloc, "/ws", "", ""))
|
|
149
138
|
|
|
150
139
|
async def _dispatch(self, event_name: str, data: dict[str, Any]) -> None:
|
|
151
140
|
model = EVENT_PAYLOAD_MODELS.get(event_name)
|
|
@@ -17,19 +17,24 @@ attenpy.egg-info/dependency_links.txt
|
|
|
17
17
|
attenpy.egg-info/requires.txt
|
|
18
18
|
attenpy.egg-info/top_level.txt
|
|
19
19
|
attenpy/endpoints/__init__.py
|
|
20
|
+
attenpy/endpoints/chats.py
|
|
20
21
|
attenpy/endpoints/explores.py
|
|
22
|
+
attenpy/endpoints/me.py
|
|
23
|
+
attenpy/endpoints/messages.py
|
|
21
24
|
attenpy/endpoints/notices.py
|
|
22
25
|
attenpy/endpoints/posts.py
|
|
23
26
|
attenpy/endpoints/users.py
|
|
24
27
|
attenpy/models/__init__.py
|
|
25
28
|
attenpy/models/attachment.py
|
|
26
29
|
attenpy/models/base.py
|
|
30
|
+
attenpy/models/bot.py
|
|
31
|
+
attenpy/models/chat.py
|
|
27
32
|
attenpy/models/notice.py
|
|
28
33
|
attenpy/models/post.py
|
|
29
34
|
attenpy/models/user.py
|
|
30
35
|
attenpy/payloads/__init__.py
|
|
36
|
+
attenpy/payloads/chat.py
|
|
31
37
|
attenpy/payloads/explore.py
|
|
32
38
|
attenpy/payloads/notice.py
|
|
33
39
|
attenpy/payloads/post.py
|
|
34
|
-
attenpy/payloads/user.py
|
|
35
|
-
attenpy/payloads/ws.py
|
|
40
|
+
attenpy/payloads/user.py
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "attenpy"
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
description = "SDK for AttenAPI"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
dependencies = ["aiohttp>=3.9.0", "pydantic>=2.0.0"]
|
|
12
|
+
license = { text = "MIT" }
|
|
13
|
+
authors = [{ name = "AttenTeam" }]
|
|
14
|
+
|
|
15
|
+
[project.urls]
|
|
16
|
+
Homepage = "https://atten.win/"
|
|
17
|
+
Repository = "https://github.com/attensns/attenpy"
|
|
18
|
+
|
|
19
|
+
[project.optional-dependencies]
|
|
20
|
+
dev = ["pytest>=7.0.0", "pytest-asyncio>=0.21.0"]
|
|
21
|
+
|
|
22
|
+
[tool.setuptools.packages.find]
|
|
23
|
+
include = ["attenpy*"]
|
|
24
|
+
|
|
25
|
+
[dependency-groups]
|
|
26
|
+
dev = ["basedpyright>=1.40.1", "ruff>=0.16.8", "ty>=0.0.95"]
|
|
27
|
+
|
|
28
|
+
[tool.ruff]
|
|
29
|
+
target-version = "py313"
|
|
30
|
+
line-length = 100
|
|
31
|
+
|
|
32
|
+
[tool.ruff.lint]
|
|
33
|
+
select = ["E", "F", "W", "I", "UP", "B", "SIM"]
|
|
34
|
+
preview = true
|
|
35
|
+
|
|
36
|
+
[tool.ruff.format]
|
|
37
|
+
quote-style = "double"
|
|
38
|
+
indent-style = "space"
|
|
39
|
+
|
|
40
|
+
[tool.ty.environment]
|
|
41
|
+
python = "./.venv"
|
attenpy-0.3.0/pyproject.toml
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61.0"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "attenpy"
|
|
7
|
-
version = "0.3.0"
|
|
8
|
-
description = "SDK for AttenAPI"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.12"
|
|
11
|
-
dependencies = [
|
|
12
|
-
"aiohttp>=3.9.0",
|
|
13
|
-
"pydantic>=2.0.0",
|
|
14
|
-
]
|
|
15
|
-
license = { text = "MIT" }
|
|
16
|
-
authors = [
|
|
17
|
-
{ name = "AttenTeam" }
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
[project.urls]
|
|
21
|
-
Homepage = "https://atten.win/"
|
|
22
|
-
Repository = "https://github.com/attensns/attenpy"
|
|
23
|
-
|
|
24
|
-
[project.optional-dependencies]
|
|
25
|
-
dev = [
|
|
26
|
-
"pytest>=7.0.0",
|
|
27
|
-
"pytest-asyncio>=0.21.0",
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
[tool.setuptools.packages.find]
|
|
31
|
-
include = ["attenpy*"]
|
|
32
|
-
|
|
33
|
-
[dependency-groups]
|
|
34
|
-
dev = [
|
|
35
|
-
"basedpyright>=1.40.1",
|
|
36
|
-
"ruff>=0.16.8",
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
[tool.ruff]
|
|
40
|
-
target-version = "py313"
|
|
41
|
-
line-length = 100
|
|
42
|
-
|
|
43
|
-
[tool.ruff.lint]
|
|
44
|
-
select = ["E","F","W","I","UP","B","SIM"]
|
|
45
|
-
preview = true
|
|
46
|
-
|
|
47
|
-
[tool.ruff.format]
|
|
48
|
-
quote-style = "double"
|
|
49
|
-
indent-style = "space"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
[tool.basedpyright]
|
|
53
|
-
pythonVersion = "3.13"
|
|
54
|
-
venvPath = "."
|
|
55
|
-
venv = ".venv"
|
|
56
|
-
|
|
57
|
-
include = ["attenpy"]
|
|
58
|
-
exclude = [
|
|
59
|
-
"**/__pycache__",
|
|
60
|
-
".venv",
|
|
61
|
-
"build",
|
|
62
|
-
"dist",
|
|
63
|
-
]
|
|
64
|
-
|
|
65
|
-
typeCheckingMode = "strict"
|
|
66
|
-
|
|
67
|
-
reportUnusedCallResult = false
|
|
68
|
-
reportMissingTypeStubs = false
|
|
69
|
-
reportImplicitOverride = false
|
|
70
|
-
reportPrivateUsage = false
|
|
71
|
-
reportUnnecessaryCast = false
|
|
72
|
-
reportUnnecessaryIsInstance = false
|
|
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
|