Skip to content

Commit

Permalink
imp: Return Reply models in get_replies
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Dec 16, 2024
1 parent 8a651e1 commit 6d8832d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions genshin/client/components/hoyolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,10 @@ async def delete_reply(self, *, reply_id: int, post_id: int) -> None:
method="POST",
)

async def get_replies(self, *, size: int = 15) -> typing.Sequence[typing.Tuple[int, str]]:
async def get_replies(self, *, size: int = 15) -> typing.Sequence[models.Reply]:
"""Get the latest replies as a list of tuples, where the first element is the reply ID and the second is the content."""
data = await self.request_bbs(
"community/post/wapi/userReply",
params=dict(size=size),
)
return [(int(i["reply"]["reply_id"]), i["reply"]["content"]) for i in data["list"]]
return [models.Reply(**i["reply"]) for i in data["list"]]
1 change: 1 addition & 0 deletions genshin/models/hoyolab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from .mimo import *
from .private import *
from .record import *
from .reply import *
11 changes: 11 additions & 0 deletions genshin/models/hoyolab/reply.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from genshin.models.model import APIModel

__all__ = ("Reply",)


class Reply(APIModel):
"""Reply model."""

post_id: int
reply_id: int
content: str

0 comments on commit 6d8832d

Please sign in to comment.