1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

add func SolveFriendRequest().

This commit is contained in:
Mrs4s 2020-07-16 22:49:45 +08:00
parent e3984eac20
commit 7fddb30e68
5 changed files with 44 additions and 2 deletions

View File

@ -50,7 +50,7 @@ qq-android协议的golang实现 移植于Mirai
- [ ] 获取/刷新讨论组列表 - [ ] 获取/刷新讨论组列表
- [x] 处理加群请求 - [x] 处理加群请求
- [x] 处理被邀请加群请求 - [x] 处理被邀请加群请求
- [ ] 处理好友请求 - [x] 处理好友请求
- [ ] 撤回群消息 - [ ] 撤回群消息
- [ ] 群公告设置 - [ ] 群公告设置
- [ ] 群设置 - [ ] 群设置

View File

@ -563,3 +563,29 @@ func (c *QQClient) buildSystemMsgGroupActionPacket(reqId, requester, group int64
packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.Pb.ReqSystemMsgAction.Group", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.Pb.ReqSystemMsgAction.Group", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet return seq, packet
} }
// ProfileService.Pb.ReqSystemMsgAction.Friend
func (c *QQClient) buildSystemMsgFriendActionPacket(reqId, requester int64, accept bool) (uint16, []byte) {
seq := c.nextSeq()
req := &structmsg.ReqSystemMsgAction{
MsgType: 1,
MsgSeq: reqId,
ReqUin: requester,
SubType: 1,
SrcId: 6,
SubSrcId: 7,
ActionInfo: &structmsg.SystemMsgActionInfo{
Type: func() int32 {
if accept {
return 2
}
return 3
}(),
Blacklist: false,
AddFrdSNInfo: &structmsg.AddFrdSNInfo{},
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.Pb.ReqSystemMsgAction.Friend", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}

View File

@ -356,6 +356,11 @@ func (c *QQClient) SolveGroupJoinRequest(i interface{}, accept bool) {
} }
} }
func (c *QQClient) SolveFriendRequest(req *NewFriendRequest, accept bool) {
_, pkt := c.buildSystemMsgFriendActionPacket(req.RequestId, req.RequesterUin, accept)
_ = c.send(pkt)
}
func (g *GroupInfo) FindMember(uin int64) *GroupMemberInfo { func (g *GroupInfo) FindMember(uin int64) *GroupMemberInfo {
for _, m := range g.Members { for _, m := range g.Members {
f := m f := m

View File

@ -229,7 +229,7 @@ func decodeMessageSvcPacket(c *QQClient, _ uint16, payload []byte) (interface{},
return nil, err return nil, err
} }
func decodeGroupMessagePacket(c *QQClient, seq uint16, payload []byte) (interface{}, error) { func decodeGroupMessagePacket(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
pkt := msg.PushMessagePacket{} pkt := msg.PushMessagePacket{}
err := proto.Unmarshal(payload, &pkt) err := proto.Unmarshal(payload, &pkt)
if err != nil { if err != nil {
@ -594,6 +594,7 @@ func decodeSystemMsgFriendPacket(c *QQClient, _ uint16, payload []byte) (interfa
Message: st.Msg.MsgAdditional, Message: st.Msg.MsgAdditional,
RequesterUin: st.ReqUin, RequesterUin: st.ReqUin,
RequesterNick: st.Msg.ReqUinNick, RequesterNick: st.Msg.ReqUinNick,
client: c,
}) })
} }
return nil, nil return nil, nil

View File

@ -130,6 +130,8 @@ type (
Message string Message string
RequesterUin int64 RequesterUin int64
RequesterNick string RequesterNick string
client *QQClient
} }
groupMemberListResponse struct { groupMemberListResponse struct {
@ -187,3 +189,11 @@ func (r *GroupInvitedRequest) Accept() {
func (r *GroupInvitedRequest) Reject() { func (r *GroupInvitedRequest) Reject() {
r.client.SolveGroupJoinRequest(r, false) r.client.SolveGroupJoinRequest(r, false)
} }
func (r *NewFriendRequest) Accept() {
r.client.SolveFriendRequest(r, true)
}
func (r *NewFriendRequest) Reject() {
r.client.SolveFriendRequest(r, false)
}