diff --git a/lagrange/client/events/friend.py b/lagrange/client/events/friend.py index 7beae68..8374eee 100644 --- a/lagrange/client/events/friend.py +++ b/lagrange/client/events/friend.py @@ -29,4 +29,11 @@ class FriendMessage(FriendEvent): class FriendRecall(FriendEvent): seq: int msg_id: int - timestamp: int \ No newline at end of file + timestamp: int + +@dataclass +class FriendRequest(FriendEvent): + from_uid: str + to_uid: str + message: str + source: str \ No newline at end of file diff --git a/lagrange/client/server_push/msg.py b/lagrange/client/server_push/msg.py index 9ef034f..3fa375b 100644 --- a/lagrange/client/server_push/msg.py +++ b/lagrange/client/server_push/msg.py @@ -18,7 +18,8 @@ PBGroupInvite, ) from lagrange.pb.status.friend import ( - PBFriendRecall + PBFriendRecall, + PBFriendRequest ) from lagrange.utils.binary.protobuf import proto_decode, ProtoStruct, proto_encode from lagrange.utils.binary.reader import Reader @@ -40,7 +41,8 @@ GroupMemberJoinedByInvite ) from ..events.friend import ( - FriendRecall + FriendRecall, + FriendRequest ) from ..wtlogin.sso import SSOPacket from .log import logger @@ -98,7 +100,17 @@ async def msg_push_handler(client: "Client", sso: SSOPacket): inn = pb.info.inner return GroupMemberJoinRequest(grp_id=inn.grp_id, uid=inn.uid, invitor_uid=inn.invitor_uid) elif typ == 0x210: # friend event, 528 / group file upload notice event - if sub_typ == 138: # friend recall + if sub_typ == 35: # friend request + pb = PBFriendRequest.decode(pkg.message.buf2) + return FriendRequest( + pkg.response_head.from_uin, + pb.info.from_uid, + pkg.response_head.to_uin, + pb.info.to_uid, + pb.info.verify, + pb.info.source + ) + elif sub_typ == 138: # friend recall pb = PBFriendRecall.decode(pkg.message.buf2) return FriendRecall( pkg.response_head.from_uin, diff --git a/lagrange/pb/status/friend.py b/lagrange/pb/status/friend.py index 1538d9b..1e3eafd 100644 --- a/lagrange/pb/status/friend.py +++ b/lagrange/pb/status/friend.py @@ -12,4 +12,13 @@ class FriendRecallInfo(ProtoStruct): div_seq: int = proto_field(9) class PBFriendRecall(ProtoStruct): - info: FriendRecallInfo = proto_field(1) \ No newline at end of file + info: FriendRecallInfo = proto_field(1) + +class FriendRequestInfo(ProtoStruct): + to_uid: str = proto_field(1) + from_uid: str = proto_field(2) + verify: str = proto_field(10) # 验证消息:我是... + source: str = proto_field(11) + +class PBFriendRequest(ProtoStruct): + info: FriendRequestInfo = proto_field(1) \ No newline at end of file