Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 3.4.0 #115

Merged
merged 11 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aiotieba/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.3.2"
__version__ = "3.4.0"
4 changes: 2 additions & 2 deletions aiotieba/api/agree/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def parse_body(body: bytes) -> None:
raise TiebaServerError(code, res_json['error_msg'])


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

Expand Down
6 changes: 3 additions & 3 deletions aiotieba/api/block/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def parse_body(body: bytes) -> None:
raise TiebaServerError(code, res_json['error_msg'])


async def request(http_core: HttpCore, fname: str, fid: int, portrait: str, day: int, reason: str) -> bool:
async def request(http_core: HttpCore, fid: int, portrait: str, day: int, reason: str) -> bool:
data = [
('BDUSS', http_core.account._BDUSS),
('day', day),
Expand All @@ -24,7 +24,7 @@ async def request(http_core: HttpCore, fname: str, fid: int, portrait: str, day:
('portrait', portrait),
('reason', reason),
('tbs', http_core.account._tbs),
('word', fname),
('word', '-'),
('z', '6'),
]

Expand All @@ -34,7 +34,7 @@ async def request(http_core: HttpCore, fname: str, fid: int, portrait: str, day:
data,
)

__log__ = f"fname={fname} portrait={portrait} day={day}"
__log__ = f"fid={fid} portrait={portrait} day={day}"

body = await send_request(request, http_core.network, read_bufsize=1024)
parse_body(body)
Expand Down
12 changes: 6 additions & 6 deletions aiotieba/api/get_ats/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class At(object):
user (UserInfo_at): 发布者的用户信息
author_id (int): 发布者的user_id

is_floor (bool): 是否楼中楼
is_comment (bool): 是否楼中楼
is_thread (bool): 是否主题帖

create_time (int): 创建时间
Expand All @@ -266,7 +266,7 @@ class At(object):
'_pid',
'_user',
'_author_id',
'_is_floor',
'_is_comment',
'_is_thread',
'_create_time',
]
Expand All @@ -278,7 +278,7 @@ def __init__(self, data_map: Mapping) -> None:
self._pid = int(data_map['post_id'])
self._user = UserInfo_at()._init(data_map['replyer'])
self._author_id = self._user._user_id
self._is_floor = bool(int(data_map['is_floor']))
self._is_comment = bool(int(data_map['is_floor']))
self._is_thread = bool(int(data_map['is_first_post']))
self._create_time = int(data_map['time'])

Expand All @@ -289,7 +289,7 @@ def __repr__(self) -> str:
'pid': self._pid,
'user': self._user.log_name,
'text': self._text,
'is_floor': self._is_floor,
'is_comment': self._is_comment,
'is_thread': self._is_thread,
}
)
Expand Down Expand Up @@ -349,12 +349,12 @@ def author_id(self) -> int:
return self._author_id

@property
def is_floor(self) -> bool:
def is_comment(self) -> bool:
"""
是否楼中楼
"""

return self._is_floor
return self._is_comment

@property
def is_thread(self) -> bool:
Expand Down
6 changes: 3 additions & 3 deletions aiotieba/api/get_blocks/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def parse_body(body: bytes) -> Blocks:
return blocks


async def request(http_core: HttpCore, fname: str, fid: int, name: str, pn: int) -> Blocks:
async def request(http_core: HttpCore, fid: int, name: str, pn: int) -> Blocks:
params = [
('fn', fname),
('fn', '-'),
('fid', fid),
('word', name),
('is_ajax', '1'),
Expand All @@ -33,7 +33,7 @@ async def request(http_core: HttpCore, fname: str, fid: int, name: str, pn: int)
params,
)

__log__ = "fname={fname}" # noqa: F841
__log__ = "fid={fid}" # noqa: F841

body = await send_request(request, http_core.network, read_bufsize=64 * 1024)
return parse_body(body)
12 changes: 6 additions & 6 deletions aiotieba/api/get_comments/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
CMD = 302002


def pack_proto(core: Account, tid: int, pid: int, pn: int, is_floor: bool) -> bytes:
def pack_proto(core: Account, tid: int, pid: int, pn: int, is_comment: bool) -> bytes:
req_proto = PbFloorReqIdl_pb2.PbFloorReqIdl()
req_proto.data.common._client_type = 2
req_proto.data.common._client_version = MAIN_VERSION
req_proto.data.tid = tid
if is_floor:
if is_comment:
req_proto.data.spid = pid
else:
req_proto.data.pid = pid
Expand All @@ -37,8 +37,8 @@ def parse_body(body: bytes) -> Comments:
return comments


async def request_http(http_core: HttpCore, tid: int, pid: int, pn: int, is_floor: bool) -> Comments:
data = pack_proto(http_core.account, tid, pid, pn, is_floor)
async def request_http(http_core: HttpCore, tid: int, pid: int, pn: int, is_comment: bool) -> Comments:
data = pack_proto(http_core.account, tid, pid, pn, is_comment)

request = pack_proto_request(
http_core,
Expand All @@ -52,8 +52,8 @@ async def request_http(http_core: HttpCore, tid: int, pid: int, pn: int, is_floo
return parse_body(body)


async def request_ws(ws_core: WsCore, tid: int, pid: int, pn: int, is_floor: bool) -> Comments:
data = pack_proto(ws_core.account, tid, pid, pn, is_floor)
async def request_ws(ws_core: WsCore, tid: int, pid: int, pn: int, is_comment: bool) -> Comments:
data = pack_proto(ws_core.account, tid, pid, pn, is_comment)

__log__ = "tid={tid} pid={pid}" # noqa: F841

Expand Down
8 changes: 4 additions & 4 deletions aiotieba/api/get_comments/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ class Comment(object):
fid (int): 所在吧id
fname (str): 所在贴吧名
tid (int): 所在主题帖id
ppid (int): 所在回复id
ppid (int): 所在楼层id
pid (int): 楼中楼id
user (UserInfo_c): 发布者的用户信息
author_id (int): 发布者的user_id
Expand Down Expand Up @@ -539,7 +539,7 @@ def tid(self) -> int:
@property
def ppid(self) -> int:
"""
所在回复id
所在楼层id
"""

return self._ppid
Expand Down Expand Up @@ -1735,7 +1735,7 @@ class Comments(Containers[Comment]):

forum (Forum_c): 所在吧信息
thread (Thread_c): 所在主题帖信息
post (Post_c): 所在回复信息
post (Post_c): 所在楼层信息
"""

__slots__ = [
Expand Down Expand Up @@ -1808,7 +1808,7 @@ def thread(self) -> Thread_c:
@property
def post(self) -> Post_c:
"""
所在回复信息
所在楼层信息
"""

return self._post
6 changes: 3 additions & 3 deletions aiotieba/api/get_posts/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ class Comment_p(object):
fid (int): 所在吧id
fname (str): 所在贴吧名
tid (int): 所在主题帖id
ppid (int): 所在回复id
ppid (int): 所在楼层id
pid (int): 楼中楼id
user (UserInfo_p): 发布者的用户信息
author_id (int): 发布者的user_id
Expand Down Expand Up @@ -590,10 +590,10 @@ def tid(self) -> int:
@property
def ppid(self) -> int:
"""
所在回复id
所在楼层id
"""

return self._pid
return self._ppid

@property
def pid(self) -> int:
Expand Down
6 changes: 3 additions & 3 deletions aiotieba/api/get_recovers/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def parse_body(body: bytes) -> Recovers:
return recovers


async def request(http_core: HttpCore, fname: str, fid: int, name: str, pn: int) -> Recovers:
async def request(http_core: HttpCore, fid: int, name: str, pn: int) -> Recovers:
params = [
('fn', fname),
('fn', '-'),
('fid', fid),
('word', name),
('is_ajax', '1'),
Expand All @@ -33,7 +33,7 @@ async def request(http_core: HttpCore, fname: str, fid: int, name: str, pn: int)
params,
)

__log__ = "fname={fname}" # noqa: F841
__log__ = "fid={fid}" # noqa: F841

body = await send_request(request, http_core.network, read_bufsize=64 * 1024)
return parse_body(body)
12 changes: 6 additions & 6 deletions aiotieba/api/get_replys/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class Reply(object):
post_user (UserInfo_reply_p): 楼层用户信息
thread_user (UserInfo_reply_t): 楼主用户信息

is_floor (bool): 是否楼中楼
is_comment (bool): 是否楼中楼
create_time (int): 创建时间
"""

Expand All @@ -433,7 +433,7 @@ class Reply(object):
'_author_id',
'_post_user',
'_thread_user',
'_is_floor',
'_is_comment',
'_create_time',
]

Expand All @@ -447,7 +447,7 @@ def __init__(self, data_proto: TypeMessage) -> None:
self._author_id = self._user._user_id
self._post_user = UserInfo_reply_p()._init(data_proto.quote_user)
self._thread_user = UserInfo_reply_t()._init(data_proto.thread_author_user)
self._is_floor = bool(data_proto.is_floor)
self._is_comment = bool(data_proto.is_floor)
self._create_time = data_proto.time

def __repr__(self) -> str:
Expand All @@ -459,7 +459,7 @@ def __repr__(self) -> str:
'text': self.text,
'post_user': self._post_user.log_name,
'thread_user': self._thread_user.log_name,
'is_floor': self._is_floor,
'is_comment': self._is_comment,
}
)

Expand Down Expand Up @@ -542,12 +542,12 @@ def thread_user(self) -> UserInfo_reply_t:
return self._thread_user

@property
def is_floor(self) -> bool:
def is_comment(self) -> bool:
"""
是否楼中楼
"""

return self._is_floor
return self._is_comment

@property
def create_time(self) -> int:
Expand Down
11 changes: 11 additions & 0 deletions aiotieba/api/get_threads/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ class UserInfo_t(object):
user_name (str): 用户名
nick_name_new (str): 新版昵称

level (int): 等级
glevel (int): 贴吧成长等级
gender (int): 性别

Expand All @@ -453,6 +454,7 @@ class UserInfo_t(object):
'_portrait',
'_user_name',
'_nick_name_new',
'_level',
'_glevel',
'_gender',
'_is_bawu',
Expand All @@ -470,6 +472,7 @@ def _init(self, data_proto: TypeMessage) -> "UserInfo_t":
self._portrait = portrait
self._user_name = data_proto.name
self._nick_name_new = data_proto.name_show
self._level = data_proto.level_id
self._glevel = data_proto.user_growth.level_id
self._gender = data_proto.gender
self._is_bawu = bool(data_proto.is_bawu)
Expand Down Expand Up @@ -565,6 +568,14 @@ def nick_name_new(self) -> str:

return self._nick_name_new

@property
def level(self) -> int:
"""
等级
"""

return self._level

@property
def glevel(self) -> int:
"""
Expand Down
6 changes: 3 additions & 3 deletions aiotieba/api/get_unblock_appeals/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def parse_body(body: bytes) -> Appeals:
return appeals


async def request(http_core: HttpCore, fname: str, fid: int, pn: int, rn: int) -> Appeals:
async def request(http_core: HttpCore, fid: int, pn: int, rn: int) -> Appeals:
data = [
('fn', fname),
('fn', '-'),
('fid', fid),
('pn', pn),
('rn', rn),
Expand All @@ -33,7 +33,7 @@ async def request(http_core: HttpCore, fname: str, fid: int, pn: int, rn: int) -
data,
)

__log__ = "fname={fname}" # noqa: F841
__log__ = "fid={fid}" # noqa: F841

body = await send_request(request, http_core.network, read_bufsize=64 * 1024)
return parse_body(body)
6 changes: 3 additions & 3 deletions aiotieba/api/get_user_contents/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class UserPost(object):
user (UserInfo_u): 发布者的用户信息
author_id (int): 发布者的user_id

is_floor (bool): 是否为楼中楼
is_comment (bool): 是否为楼中楼

create_time (int): 创建时间
"""
Expand All @@ -263,14 +263,14 @@ class UserPost(object):
'_pid',
'_user',
'_author_id',
'_is_floor',
'_is_comment',
'_create_time',
]

def __init__(self, data_proto: TypeMessage) -> None:
self._contents = Contents_up()._init(data_proto.post_content)
self._pid = data_proto.post_id
self._is_floor = bool(data_proto.post_type)
self._is_comment = bool(data_proto.post_type)
self._create_time = data_proto.create_time

def __repr__(self) -> str:
Expand Down
6 changes: 3 additions & 3 deletions aiotieba/api/handle_unblock_appeals/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def parse_body(body: bytes) -> None:
raise TiebaServerError(code, res_json['error'])


async def request(http_core: HttpCore, fname: str, fid: int, appeal_ids: List[int], refuse: bool) -> bool:
async def request(http_core: HttpCore, fid: int, appeal_ids: List[int], refuse: bool) -> bool:
data = (
[
('fn', fname),
('fn', '-'),
('fid', fid),
]
+ [(f'appeal_list[{i}]', appeal_id) for i, appeal_id in enumerate(appeal_ids)]
Expand All @@ -36,7 +36,7 @@ async def request(http_core: HttpCore, fname: str, fid: int, appeal_ids: List[in
data,
)

__log__ = f"fname={fname}"
__log__ = f"fid={fid}"

body = await send_request(request, http_core.network, read_bufsize=1024)
parse_body(body)
Expand Down
Loading