Skip to content

Commit d51c7c9

Browse files
HornCopperwyapx
andauthored
feat(event): FriendRequest (#38)
Co-authored-by: nullcat <[email protected]>
1 parent bf43226 commit d51c7c9

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

lagrange/client/events/friend.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ class FriendMessage(FriendEvent):
2929
class FriendRecall(FriendEvent):
3030
seq: int
3131
msg_id: int
32-
timestamp: int
32+
timestamp: int
33+
34+
@dataclass
35+
class FriendRequest(FriendEvent):
36+
from_uid: str
37+
to_uid: str
38+
message: str
39+
source: str

lagrange/client/server_push/msg.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
PBGroupInvite,
1919
)
2020
from lagrange.pb.status.friend import (
21-
PBFriendRecall
21+
PBFriendRecall,
22+
PBFriendRequest
2223
)
2324
from lagrange.utils.binary.protobuf import proto_decode, ProtoStruct, proto_encode
2425
from lagrange.utils.binary.reader import Reader
@@ -40,7 +41,8 @@
4041
GroupMemberJoinedByInvite
4142
)
4243
from ..events.friend import (
43-
FriendRecall
44+
FriendRecall,
45+
FriendRequest
4446
)
4547
from ..wtlogin.sso import SSOPacket
4648
from .log import logger
@@ -98,7 +100,17 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
98100
inn = pb.info.inner
99101
return GroupMemberJoinRequest(grp_id=inn.grp_id, uid=inn.uid, invitor_uid=inn.invitor_uid)
100102
elif typ == 0x210: # friend event, 528 / group file upload notice event
101-
if sub_typ == 138: # friend recall
103+
if sub_typ == 35: # friend request
104+
pb = PBFriendRequest.decode(pkg.message.buf2)
105+
return FriendRequest(
106+
pkg.response_head.from_uin,
107+
pb.info.from_uid,
108+
pkg.response_head.to_uin,
109+
pb.info.to_uid,
110+
pb.info.verify,
111+
pb.info.source
112+
)
113+
elif sub_typ == 138: # friend recall
102114
pb = PBFriendRecall.decode(pkg.message.buf2)
103115
return FriendRecall(
104116
pkg.response_head.from_uin,

lagrange/pb/status/friend.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,13 @@ class FriendRecallInfo(ProtoStruct):
1212
div_seq: int = proto_field(9)
1313

1414
class PBFriendRecall(ProtoStruct):
15-
info: FriendRecallInfo = proto_field(1)
15+
info: FriendRecallInfo = proto_field(1)
16+
17+
class FriendRequestInfo(ProtoStruct):
18+
to_uid: str = proto_field(1)
19+
from_uid: str = proto_field(2)
20+
verify: str = proto_field(10) # 验证消息:我是...
21+
source: str = proto_field(11)
22+
23+
class PBFriendRequest(ProtoStruct):
24+
info: FriendRequestInfo = proto_field(1)

0 commit comments

Comments
 (0)