Skip to content

Commit

Permalink
feat: drop supporting of folding posts
Browse files Browse the repository at this point in the history
  • Loading branch information
lumina37 committed May 24, 2023
1 parent df93a72 commit c999767
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 54 deletions.
2 changes: 1 addition & 1 deletion aiotieba/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.4.2a1"
__version__ = "3.4.2a2"
6 changes: 0 additions & 6 deletions aiotieba/api/get_posts/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def pack_proto(
with_comments: bool,
comment_sort_by_agree: bool,
comment_rn: int,
is_fold: bool,
) -> bytes:
req_proto = PbPageReqIdl_pb2.PbPageReqIdl()
req_proto.data.common._client_type = 2
Expand All @@ -30,7 +29,6 @@ def pack_proto(
req_proto.data.rn = rn if rn > 1 else 2
req_proto.data.sort = sort
req_proto.data.only_thread_author = only_thread_author
req_proto.data.is_fold = is_fold
if with_comments:
req_proto.data.common.BDUSS = core._BDUSS
req_proto.data.with_comments = with_comments
Expand Down Expand Up @@ -63,7 +61,6 @@ async def request_http(
with_comments: bool,
comment_sort_by_agree: bool,
comment_rn: int,
is_fold: bool,
) -> Posts:
data = pack_proto(
http_core.account,
Expand All @@ -75,7 +72,6 @@ async def request_http(
with_comments,
comment_sort_by_agree,
comment_rn,
is_fold,
)

request = pack_proto_request(
Expand All @@ -100,7 +96,6 @@ async def request_ws(
with_comments: bool,
comment_sort_by_agree: bool,
comment_rn: int,
is_fold: bool,
) -> Posts:
data = pack_proto(
ws_core.account,
Expand All @@ -112,7 +107,6 @@ async def request_ws(
with_comments,
comment_sort_by_agree,
comment_rn,
is_fold,
)

__log__ = "tid={tid}" # noqa: F841
Expand Down
13 changes: 0 additions & 13 deletions aiotieba/api/get_posts/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -2256,23 +2256,19 @@ class Posts(Containers[Post]):
forum (Forum_p): 所在吧信息
thread (Thread_p): 所在主题帖信息
has_fold (bool): 是否存在折叠楼层
"""

__slots__ = [
'_page',
'_forum',
'_thread',
'_has_fold',
]

def __init__(self, data_proto: Optional[TypeMessage] = None) -> None:
if data_proto:
self._page = Page_p()._init(data_proto.page)
self._forum = Forum_p()._init(data_proto.forum)
self._thread = Thread_p()._init(data_proto.thread)
self._has_fold = bool(data_proto.has_fold_comment)

self._thread._fid = self._forum._fid
self._thread._fname = self._forum._fname
Expand All @@ -2299,7 +2295,6 @@ def __init__(self, data_proto: Optional[TypeMessage] = None) -> None:
self._page = Page_p()._init_null()
self._forum = Forum_p()._init_null()
self._thread = Thread_p()._init_null()
self._has_fold = False

@property
def page(self) -> Page_p:
Expand Down Expand Up @@ -2332,11 +2327,3 @@ def thread(self) -> Thread_p:
"""

return self._thread

@property
def has_fold(self) -> bool:
"""
是否存在折叠楼层
"""

return self._has_fold
1 change: 0 additions & 1 deletion aiotieba/api/get_posts/protobuf/PbPageReqIdl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ message PbPageReqIdl {
int32 rn = 13;
int32 pn = 18;
int32 comment_sort_by_agree = 74;
int32 is_fold = 78;
}
DataReq data = 1;
}
6 changes: 3 additions & 3 deletions aiotieba/api/get_posts/protobuf/PbPageReqIdl_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ..._protobuf import CommonReq_pb2 as CommonReq__pb2

DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
b'\n\x12PbPageReqIdl.proto\x1a\x0f\x43ommonReq.proto\"\x92\x02\n\x0cPbPageReqIdl\x12#\n\x04\x64\x61ta\x18\x01 \x01(\x0b\x32\x15.PbPageReqIdl.DataReq\x1a\xdc\x01\n\x07\x44\x61taReq\x12\x1a\n\x06\x63ommon\x18\x19 \x01(\x0b\x32\n.CommonReq\x12\x0b\n\x03tid\x18\x04 \x01(\x03\x12\x1a\n\x12only_thread_author\x18\x05 \x01(\x05\x12\x0c\n\x04sort\x18\x06 \x01(\x05\x12\x0b\n\x03pid\x18\x07 \x01(\x03\x12\x15\n\rwith_comments\x18\x08 \x01(\x05\x12\x12\n\ncomment_rn\x18\t \x01(\x05\x12\n\n\x02rn\x18\r \x01(\x05\x12\n\n\x02pn\x18\x12 \x01(\x05\x12\x1d\n\x15\x63omment_sort_by_agree\x18J \x01(\x05\x12\x0f\n\x07is_fold\x18N \x01(\x05\x62\x06proto3'
b'\n\x12PbPageReqIdl.proto\x1a\x0f\x43ommonReq.proto\"\x81\x02\n\x0cPbPageReqIdl\x12#\n\x04\x64\x61ta\x18\x01 \x01(\x0b\x32\x15.PbPageReqIdl.DataReq\x1a\xcb\x01\n\x07\x44\x61taReq\x12\x1a\n\x06\x63ommon\x18\x19 \x01(\x0b\x32\n.CommonReq\x12\x0b\n\x03tid\x18\x04 \x01(\x03\x12\x1a\n\x12only_thread_author\x18\x05 \x01(\x05\x12\x0c\n\x04sort\x18\x06 \x01(\x05\x12\x0b\n\x03pid\x18\x07 \x01(\x03\x12\x15\n\rwith_comments\x18\x08 \x01(\x05\x12\x12\n\ncomment_rn\x18\t \x01(\x05\x12\n\n\x02rn\x18\r \x01(\x05\x12\n\n\x02pn\x18\x12 \x01(\x05\x12\x1d\n\x15\x63omment_sort_by_agree\x18J \x01(\x05\x62\x06proto3'
)

_globals = globals()
Expand All @@ -19,6 +19,6 @@
if _descriptor._USE_C_DESCRIPTORS is False:
DESCRIPTOR._options = None
_globals['_PBPAGEREQIDL']._serialized_start = 40
_globals['_PBPAGEREQIDL']._serialized_end = 314
_globals['_PBPAGEREQIDL']._serialized_end = 297
_globals['_PBPAGEREQIDL_DATAREQ']._serialized_start = 94
_globals['_PBPAGEREQIDL_DATAREQ']._serialized_end = 314
_globals['_PBPAGEREQIDL_DATAREQ']._serialized_end = 297
1 change: 0 additions & 1 deletion aiotieba/api/get_posts/protobuf/PbPageResIdl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ message PbPageResIdl {
repeated Post post_list = 6;
ThreadInfo thread = 8;
repeated User user_list = 13;
int32 has_fold_comment = 68;
}
DataRes data = 2;
}
6 changes: 3 additions & 3 deletions aiotieba/api/get_posts/protobuf/PbPageResIdl_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..._protobuf import User_pb2 as User__pb2

DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
b'\n\x12PbPageResIdl.proto\x1a\x0b\x45rror.proto\x1a\x11SimpleForum.proto\x1a\nPage.proto\x1a\nPost.proto\x1a\x10ThreadInfo.proto\x1a\nUser.proto\"\xf3\x01\n\x0cPbPageResIdl\x12\x15\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x06.Error\x12#\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x15.PbPageResIdl.DataRes\x1a\xa6\x01\n\x07\x44\x61taRes\x12\x1b\n\x05\x66orum\x18\x02 \x01(\x0b\x32\x0c.SimpleForum\x12\x13\n\x04page\x18\x03 \x01(\x0b\x32\x05.Page\x12\x18\n\tpost_list\x18\x06 \x03(\x0b\x32\x05.Post\x12\x1b\n\x06thread\x18\x08 \x01(\x0b\x32\x0b.ThreadInfo\x12\x18\n\tuser_list\x18\r \x03(\x0b\x32\x05.User\x12\x18\n\x10has_fold_comment\x18\x44 \x01(\x05\x62\x06proto3'
b'\n\x12PbPageResIdl.proto\x1a\x0b\x45rror.proto\x1a\x11SimpleForum.proto\x1a\nPage.proto\x1a\nPost.proto\x1a\x10ThreadInfo.proto\x1a\nUser.proto\"\xd9\x01\n\x0cPbPageResIdl\x12\x15\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x06.Error\x12#\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x15.PbPageResIdl.DataRes\x1a\x8c\x01\n\x07\x44\x61taRes\x12\x1b\n\x05\x66orum\x18\x02 \x01(\x0b\x32\x0c.SimpleForum\x12\x13\n\x04page\x18\x03 \x01(\x0b\x32\x05.Page\x12\x18\n\tpost_list\x18\x06 \x03(\x0b\x32\x05.Post\x12\x1b\n\x06thread\x18\x08 \x01(\x0b\x32\x0b.ThreadInfo\x12\x18\n\tuser_list\x18\r \x03(\x0b\x32\x05.Userb\x06proto3'
)

_globals = globals()
Expand All @@ -24,6 +24,6 @@
if _descriptor._USE_C_DESCRIPTORS is False:
DESCRIPTOR._options = None
_globals['_PBPAGERESIDL']._serialized_start = 109
_globals['_PBPAGERESIDL']._serialized_end = 352
_globals['_PBPAGERESIDL']._serialized_end = 326
_globals['_PBPAGERESIDL_DATARES']._serialized_start = 186
_globals['_PBPAGERESIDL_DATARES']._serialized_end = 352
_globals['_PBPAGERESIDL_DATARES']._serialized_end = 326
24 changes: 2 additions & 22 deletions aiotieba/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ async def get_posts(
with_comments: bool = False,
comment_sort_by_agree: bool = True,
comment_rn: int = 4,
is_fold: bool = False,
) -> get_posts.Posts:
"""
获取主题帖内回复
Expand All @@ -539,37 +538,18 @@ async def get_posts(
with_comments (bool, optional): True则同时请求高赞楼中楼 False则返回的Posts.comments为空. Defaults to False.
comment_sort_by_agree (bool, optional): True则楼中楼按点赞数顺序 False则楼中楼按时间顺序. Defaults to True.
comment_rn (int, optional): 请求的楼中楼数量. Defaults to 4. Max to 50.
is_fold (bool, optional): 是否请求被折叠的回复. Defaults to False.
Returns:
Posts: 回复列表
"""

if self._ws_core.status == WsStatus.OPEN:
return await get_posts.request_ws(
self._ws_core,
tid,
pn,
rn,
sort,
only_thread_author,
with_comments,
comment_sort_by_agree,
comment_rn,
is_fold,
self._ws_core, tid, pn, rn, sort, only_thread_author, with_comments, comment_sort_by_agree, comment_rn
)

return await get_posts.request_http(
self._http_core,
tid,
pn,
rn,
sort,
only_thread_author,
with_comments,
comment_sort_by_agree,
comment_rn,
is_fold,
self._http_core, tid, pn, rn, sort, only_thread_author, with_comments, comment_sort_by_agree, comment_rn
)

@handle_exception(get_comments.Comments)
Expand Down
2 changes: 0 additions & 2 deletions docs/ref/classdef.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,6 @@ def `__bool__`() -> *bool*
**forum** - *([BasicForum](#basicforum))* 所在吧信息

**thread** - *([Thread](#thread))* 所在主题帖信息

**has_fold** - *(bool)* 是否存在折叠楼层
</div>

## Comment
Expand Down
3 changes: 1 addition & 2 deletions docs/ref/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def `get_threads`(*fname_or_fid: str | int*, /, *pn: int = 1*, \*, *rn: in
**返回**: 帖子列表
</div>

async def `get_posts`(*tid: int*, /, *pn: int = 1*, \*, *rn: int = 30*, *sort: PostSortType = PostSortType.ASC*, *only_thread_author: bool = False*, *with_comments: bool = False*, *comment_sort_by_agree: bool = True*, *comment_rn: int = 4*, *is_fold: bool = False*) -> *[Posts](classdef.md#posts)*
async def `get_posts`(*tid: int*, /, *pn: int = 1*, \*, *rn: int = 30*, *sort: PostSortType = PostSortType.ASC*, *only_thread_author: bool = False*, *with_comments: bool = False*, *comment_sort_by_agree: bool = True*, *comment_rn: int = 4*) -> *[Posts](classdef.md#posts)*

<div class="docstring" markdown="1">
获取回复列表
Expand All @@ -117,7 +117,6 @@ async def `get_posts`(*tid: int*, /, *pn: int = 1*, \*, *rn: int = 30*, *sort: P
+ with_comments: True则同时请求高赞楼中楼 False则返回的Posts.comments为空
+ comment_sort_by_agree: True则楼中楼按点赞数顺序 False则楼中楼按时间顺序
+ comment_rn: 请求的楼中楼数量
+ is_fold: 是否请求被折叠的回复

**返回**: 回复列表
</div>
Expand Down
1 change: 1 addition & 0 deletions tests/test_get_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ async def test_Comments(client: tb.Client):
comment = comments[1]
assert comment.reply_to_id != 0


@pytest.mark.flaky(reruns=3, reruns_delay=2.0)
@pytest.mark.asyncio
async def test_FragLink(client: tb.Client):
Expand Down

0 comments on commit c999767

Please sign in to comment.