Skip to content

feat(event): FriendRequest #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lagrange/client/events/friend.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@ class FriendMessage(FriendEvent):
class FriendRecall(FriendEvent):
seq: int
msg_id: int
timestamp: int
timestamp: int

@dataclass
class FriendRequest(FriendEvent):
from_uid: str
to_uid: str
message: str
source: str
18 changes: 15 additions & 3 deletions lagrange/client/server_push/msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +41,8 @@
GroupMemberJoinedByInvite
)
from ..events.friend import (
FriendRecall
FriendRecall,
FriendRequest
)
from ..wtlogin.sso import SSOPacket
from .log import logger
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion lagrange/pb/status/friend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ class FriendRecallInfo(ProtoStruct):
div_seq: int = proto_field(9)

class PBFriendRecall(ProtoStruct):
info: FriendRecallInfo = proto_field(1)
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)