Skip to content

Commit

Permalink
fix: support floor agree
Browse files Browse the repository at this point in the history
  • Loading branch information
Starry-OvO committed Mar 18, 2023
1 parent 7fa45b6 commit 79502d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion aiotieba/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.3.1"
__version__ = "3.3.2a0"
9 changes: 7 additions & 2 deletions aiotieba/api/agree/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ def parse_body(body: bytes) -> None:
raise TiebaServerError(code, res_json['error_msg'])


async def request(http_core: HttpCore, tid: int, pid: int, is_disagree: bool, is_undo: bool) -> bool:
async def request(http_core: HttpCore, tid: int, pid: int, is_floor: bool, is_disagree: bool, is_undo: bool) -> bool:
if pid:
obj_type = '2' if is_floor else '1'
else:
obj_type = '3'

data = [
('BDUSS', http_core.account._BDUSS),
('_client_version', MAIN_VERSION),
('agree_type', '5' if is_disagree else '2'),
('cuid', http_core.account.cuid_galaxy2),
('obj_type', '1' if pid else '3'),
('obj_type', obj_type),
('op_type', str(int(is_undo))),
('post_id', pid),
('tbs', http_core.account._tbs),
Expand Down
20 changes: 12 additions & 8 deletions aiotieba/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1694,13 +1694,14 @@ async def get_dislike_forums(self, pn: int = 1, /, *, rn: int = 20) -> get_disli
return await get_dislike_forums.request_http(self._http_core, pn, rn)

@handle_exception(bool, no_format=True)
async def agree(self, tid: int, pid: int = 0) -> bool:
async def agree(self, tid: int, pid: int = 0, is_floor: bool = False) -> bool:
"""
点赞主题帖或回复
Args:
tid (int): 待点赞的主题帖或回复所在的主题帖的tid
pid (int, optional): 待点赞的回复pid. Defaults to 0.
is_floor (bool, optional): pid是否指向楼中楼. Defaults to False.
Returns:
bool: True成功 False失败
Expand All @@ -1712,58 +1713,61 @@ async def agree(self, tid: int, pid: int = 0) -> bool:

await self.__init_tbs()

return await agree.request(self._http_core, tid, pid, is_disagree=False, is_undo=False)
return await agree.request(self._http_core, tid, pid, is_floor, is_disagree=False, is_undo=False)

@handle_exception(bool, no_format=True)
async def unagree(self, tid: int, pid: int = 0) -> bool:
async def unagree(self, tid: int, pid: int = 0, is_floor: bool = False) -> bool:
"""
取消点赞主题帖或回复
Args:
tid (int): 待取消点赞的主题帖或回复所在的主题帖的tid
pid (int, optional): 待取消点赞的回复pid. Defaults to 0.
is_floor (bool, optional): pid是否指向楼中楼. Defaults to False.
Returns:
bool: True成功 False失败
"""

await self.__init_tbs()

return await agree.request(self._http_core, tid, pid, is_disagree=False, is_undo=True)
return await agree.request(self._http_core, tid, pid, is_floor, is_disagree=False, is_undo=True)

@handle_exception(bool, no_format=True)
async def disagree(self, tid: int, pid: int = 0) -> bool:
async def disagree(self, tid: int, pid: int = 0, is_floor: bool = False) -> bool:
"""
点踩主题帖或回复
Args:
tid (int): 待点踩的主题帖或回复所在的主题帖的tid
pid (int, optional): 待点踩的回复pid. Defaults to 0.
is_floor (bool, optional): pid是否指向楼中楼. Defaults to False.
Returns:
bool: True成功 False失败
"""

await self.__init_tbs()

return await agree.request(self._http_core, tid, pid, is_disagree=True, is_undo=False)
return await agree.request(self._http_core, tid, pid, is_floor, is_disagree=True, is_undo=False)

@handle_exception(bool, no_format=True)
async def undisagree(self, tid: int, pid: int = 0) -> bool:
async def undisagree(self, tid: int, pid: int = 0, is_floor: bool = False) -> bool:
"""
取消点踩主题帖或回复
Args:
tid (int): 待取消点踩的主题帖或回复所在的主题帖的tid
pid (int, optional): 待取消点踩的回复pid. Defaults to 0.
is_floor (bool, optional): pid是否指向楼中楼. Defaults to False.
Returns:
bool: True成功 False失败
"""

await self.__init_tbs()

return await agree.request(self._http_core, tid, pid, is_disagree=True, is_undo=True)
return await agree.request(self._http_core, tid, pid, is_floor, is_disagree=True, is_undo=True)

@handle_exception(bool, no_format=True)
async def agree_vimage(self, _id: Union[str, int]) -> bool:
Expand Down

0 comments on commit 79502d3

Please sign in to comment.