From 8a651e1552e9d3ef5890ab72a1ef653ff4966ccb Mon Sep 17 00:00:00 2001 From: seria Date: Mon, 16 Dec 2024 21:48:24 +0900 Subject: [PATCH] feat: Add get_replies method --- genshin/client/components/hoyolab.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/genshin/client/components/hoyolab.py b/genshin/client/components/hoyolab.py index 394caf49..f5beaffc 100644 --- a/genshin/client/components/hoyolab.py +++ b/genshin/client/components/hoyolab.py @@ -445,3 +445,11 @@ async def delete_reply(self, *, reply_id: int, post_id: int) -> None: data=dict(reply_id=reply_id, post_id=post_id), method="POST", ) + + async def get_replies(self, *, size: int = 15) -> typing.Sequence[typing.Tuple[int, str]]: + """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"]]