Skip to content

Commit a05321c

Browse files
authored
feat(event): GroupInviteAccept event & GroupRecall event (#37)
1 parent 0ad468f commit a05321c

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

lagrange/client/events/friend.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ class FriendMessage(FriendEvent):
2323
timestamp: int
2424
msg: str
2525
msg_chain: list[Element]
26+
27+
28+
@dataclass
29+
class FriendRecall(FriendEvent):
30+
seq: int
31+
msg_id: int
32+
timestamp: int

lagrange/client/events/group.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,9 @@ class GroupAlbumUpdate(GroupEvent):
147147
@dataclass
148148
class GroupInvite(GroupEvent):
149149
invitor_uid: str
150+
151+
152+
@dataclass
153+
class GroupInviteAccept(GroupEvent):
154+
invitor_uin: int
155+
uin: int

lagrange/client/server_push/msg.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
PBGroupAlbumUpdate,
1818
PBGroupInvite,
1919
)
20+
from lagrange.pb.status.friend import (
21+
PBFriendRecall
22+
)
2023
from lagrange.utils.binary.protobuf import proto_decode, ProtoStruct, proto_encode
2124
from lagrange.utils.binary.reader import Reader
2225
from lagrange.utils.operator import unpack_dict, timestamp
@@ -34,6 +37,10 @@
3437
GroupReaction,
3538
GroupSign,
3639
GroupAlbumUpdate,
40+
GroupInviteAccept
41+
)
42+
from ..events.friend import (
43+
FriendRecall
3744
)
3845
from ..wtlogin.sso import SSOPacket
3946
from .log import logger
@@ -90,7 +97,18 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
9097
if pb.cmd == 87:
9198
inn = pb.info.inner
9299
return GroupMemberJoinRequest(grp_id=inn.grp_id, uid=inn.uid, invitor_uid=inn.invitor_uid)
93-
elif typ == 0x210: # friend event / group file upload notice event
100+
elif typ == 0x210: # friend event, 528 / group file upload notice event
101+
if sub_typ == 138: # friend recall
102+
pb = PBFriendRecall.decode(pkg.message.buf2)
103+
return FriendRecall(
104+
pkg.response_head.from_uin,
105+
pb.info.from_uid,
106+
pkg.response_head.to_uin,
107+
pb.info.to_uid,
108+
pb.info.seq,
109+
pb.info.random,
110+
pb.info.time
111+
)
94112
logger.debug(f"unhandled friend event / group file upload notice event: {pkg}") # TODO: paste
95113
elif typ == 0x2DC: # grp event, 732
96114
if sub_typ == 20: # nudge and group_sign(群打卡)
@@ -106,6 +124,12 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
106124
attrs[k.decode()] = int(v.decode())
107125
else:
108126
attrs[k.decode()] = v.decode()
127+
if pb.body.type == 1:
128+
return GroupInviteAccept(
129+
grp_id,
130+
attrs["invitor"],
131+
attrs["invitee"]
132+
)
109133
if pb.body.type == 12:
110134
return GroupNudge(
111135
grp_id,

lagrange/pb/status/friend.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from lagrange.utils.binary.protobuf import proto_field, ProtoStruct
2+
3+
class FriendRecallInfo(ProtoStruct):
4+
from_uid: str = proto_field(1)
5+
to_uid: str = proto_field(2)
6+
seq: int = proto_field(3)
7+
new_id: int = proto_field(4)
8+
time: int = proto_field(5)
9+
random: int = proto_field(6)
10+
package_num: int = proto_field(7)
11+
package_index: int = proto_field(8)
12+
div_seq: int = proto_field(9)
13+
14+
class PBFriendRecall(ProtoStruct):
15+
info: FriendRecallInfo = proto_field(1)

0 commit comments

Comments
 (0)