Skip to content

Commit a225f41

Browse files
committed
feat(client): add get_grp_last_seq
1 parent 378d3e9 commit a225f41

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

lagrange/client/client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
SetEssenceRsp,
4747
GetInfoFromUidRsp,
4848
PBGetInfoFromUidReq,
49+
PBGetGrpLastSeq,
50+
GetGrpLastSeqRsp,
4951
)
5052
from lagrange.pb.service.oidb import OidbRequest, OidbResponse
5153
from lagrange.pb.highway.comm import IndexNode
@@ -559,3 +561,17 @@ async def get_user_info(
559561
return UserInfo.from_pb(rsp.body[0])
560562
else:
561563
return [UserInfo.from_pb(body) for body in rsp.body]
564+
565+
async def get_group_last_seq(self, grp_id: int) -> int:
566+
rsp = GetGrpLastSeqRsp.decode(
567+
(
568+
await self.send_oidb_svc(
569+
0x88D,
570+
0,
571+
PBGetGrpLastSeq.build(self.app_info.sub_app_id, grp_id).encode(),
572+
)
573+
).data
574+
)
575+
if not rsp.body.args.seq:
576+
raise AssertionError("No message found")
577+
return rsp.body.args.seq

lagrange/pb/service/group.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ class PBGetGrpMemberInfoReq(ProtoStruct):
287287
next_key: Optional[bytes] = proto_field(15, default=None) # base64(pb)
288288

289289
@classmethod
290-
def build(cls, grp_id: int, uid="", next_key: Optional[str] = None) -> "PBGetGrpMemberInfoReq":
290+
def build(
291+
cls, grp_id: int, uid="", next_key: Optional[str] = None
292+
) -> "PBGetGrpMemberInfoReq":
291293
assert not (uid and next_key), "invalid arguments"
292294
if uid:
293295
account = AccountInfo(uid=uid)
@@ -434,3 +436,34 @@ class GetInfoRspBody(ProtoStruct):
434436

435437
class GetInfoFromUidRsp(ProtoStruct):
436438
body: list[GetInfoRspBody] = proto_field(1)
439+
440+
441+
class Oidb88D0Args(ProtoStruct):
442+
seq: Optional[int] = proto_field(22, default=None)
443+
444+
445+
class GetGrpLastSeqReqBody(ProtoStruct):
446+
grp_id: int = proto_field(1)
447+
args: Oidb88D0Args = proto_field(2, default=Oidb88D0Args(seq=0))
448+
449+
450+
class PBGetGrpLastSeq(ProtoStruct):
451+
apk_sub_id: int = proto_field(1)
452+
body: GetGrpLastSeqReqBody = proto_field(2)
453+
454+
@classmethod
455+
def build(cls, apk_subid: int, grp_id: int) -> "PBGetGrpLastSeq":
456+
return cls(
457+
apk_sub_id=apk_subid,
458+
body=GetGrpLastSeqReqBody(grp_id=grp_id),
459+
)
460+
461+
462+
class GetGrpLastSeqRspBody(ProtoStruct):
463+
grp_id: int = proto_field(1)
464+
# f2: int = proto_field(2) # 0
465+
args: Oidb88D0Args = proto_field(3)
466+
467+
468+
class GetGrpLastSeqRsp(ProtoStruct):
469+
body: GetGrpLastSeqRspBody = proto_field(1)

0 commit comments

Comments
 (0)