-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
271 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "3.1.5a1" | ||
__version__ = "3.1.5a2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
aiotieba/client/_websocket/protobuf/UpdateClientInfoResIdl_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from ._api import CMD, pack_proto, parse_body | ||
from ._classdef import MsgGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import List | ||
|
||
from .._core import TbCore | ||
from .._exception import TiebaServerError | ||
from ._classdef import MsgGroup | ||
from .protobuf import GetGroupMsgReqIdl_pb2, GetGroupMsgResIdl_pb2 | ||
|
||
CMD = 202003 | ||
|
||
|
||
def pack_proto(core: TbCore, groups: List[MsgGroup], get_type: int) -> bytes: | ||
req_proto = GetGroupMsgReqIdl_pb2.GetGroupMsgReqIdl() | ||
for group in groups: | ||
group_proto = req_proto.data.groupMids.add() | ||
group_proto.groupId = group._group_type | ||
group_proto.lastMsgId = group._last_msg_id | ||
req_proto.data.gettype = str(get_type) | ||
req_proto.cuid = f"{core.cuid}|com.baidu.tieba_mini{core.post_version}" | ||
|
||
return req_proto.SerializeToString() | ||
|
||
|
||
def parse_body(body: bytes) -> None: | ||
res_proto = GetGroupMsgResIdl_pb2.GetGroupMsgResIdl() | ||
res_proto.ParseFromString(body) | ||
|
||
if code := res_proto.error.errorno: | ||
raise TiebaServerError(code, res_proto.error.errmsg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class MsgGroup(object): | ||
|
||
__slots__ = [ | ||
'_group_type', | ||
'_last_msg_id', | ||
] | ||
|
||
def __init__(self, group_type: int, last_msg_id: int) -> None: | ||
self._group_type = group_type | ||
self._last_msg_id = last_msg_id | ||
|
||
def __repr__(self) -> str: | ||
return str( | ||
{ | ||
'group_type': self._group_type, | ||
'last_msg_id': self._last_msg_id, | ||
} | ||
) | ||
|
||
def group_type(self) -> int: | ||
""" | ||
消息组类别 | ||
Returns: | ||
int | ||
""" | ||
|
||
return self._group_type | ||
|
||
def last_msg_id(self) -> int: | ||
""" | ||
最后一条消息的id | ||
Returns: | ||
int | ||
""" | ||
|
||
return self._last_msg_id |
15 changes: 15 additions & 0 deletions
15
aiotieba/client/get_group_msg/protobuf/GetGroupMsgReqIdl.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// protobuf.CommitPersonalMsg.CommitPersonalMsgReqIdl | ||
syntax = "proto3"; | ||
|
||
message GetGroupMsgReqIdl { | ||
string cuid = 1; | ||
message DataReq { | ||
message GroupLastId { | ||
int64 groupId = 1; | ||
int64 lastMsgId = 2; | ||
} | ||
repeated GroupLastId groupMids = 6; | ||
string gettype = 7; | ||
} | ||
DataReq data = 2; | ||
} |
29 changes: 29 additions & 0 deletions
29
aiotieba/client/get_group_msg/protobuf/GetGroupMsgReqIdl_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
aiotieba/client/get_group_msg/protobuf/GetGroupMsgResIdl.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// protobuf.CommitPersonalMsg.CommitPersonalMsgResIdl | ||
syntax = "proto3"; | ||
|
||
import "Error.proto"; | ||
|
||
message GetGroupMsgResIdl { | ||
Error error = 1; | ||
} |
26 changes: 26 additions & 0 deletions
26
aiotieba/client/get_group_msg/protobuf/GetGroupMsgResIdl_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from ._api import CMD, parse_body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from ..get_group_msg import MsgGroup | ||
from .protobuf import PushNotifyResIdl_pb2 | ||
|
||
CMD = 202006 | ||
|
||
|
||
def parse_body(body: bytes) -> MsgGroup: | ||
res_proto = PushNotifyResIdl_pb2.PushNotifyResIdl() | ||
res_proto.ParseFromString(body) | ||
|
||
group_proto = res_proto.multiMsg[0].data | ||
group = MsgGroup(group_proto.groupId, group_proto.msgId) | ||
|
||
return group |
Oops, something went wrong.