diff --git a/client/builders.go b/client/builders.go index 2f70e0f8..a947d6d6 100644 --- a/client/builders.go +++ b/client/builders.go @@ -3,6 +3,9 @@ package client import ( "crypto/md5" "encoding/hex" + "math/rand" + "strconv" + "github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/binary/jce" "github.com/Mrs4s/MiraiGo/client/pb" @@ -18,8 +21,6 @@ import ( "github.com/Mrs4s/MiraiGo/protocol/tlv" "github.com/Mrs4s/MiraiGo/utils" "github.com/golang/protobuf/proto" - "math/rand" - "strconv" ) var ( @@ -680,7 +681,7 @@ func (c *QQClient) buildSystemMsgNewFriendPacket() (uint16, []byte) { } // ProfileService.Pb.ReqSystemMsgAction.Group -func (c *QQClient) buildSystemMsgGroupActionPacket(reqId, requester, group int64, isInvite, accept, block bool) (uint16, []byte) { +func (c *QQClient) buildSystemMsgGroupActionPacket(reqId, requester, group int64, isInvite, accept, block bool, reason string) (uint16, []byte) { seq := c.nextSeq() req := &structmsg.ReqSystemMsgAction{ MsgType: 1, @@ -709,6 +710,7 @@ func (c *QQClient) buildSystemMsgGroupActionPacket(reqId, requester, group int64 }(), GroupCode: group, Blacklist: block, + Msg: reason, Sig: EmptyBytes, }, Language: 1000, diff --git a/client/client.go b/client/client.go index ba1a8123..40b19af7 100644 --- a/client/client.go +++ b/client/client.go @@ -707,13 +707,18 @@ func (c *QQClient) FindGroup(code int64) *GroupInfo { return nil } -func (c *QQClient) SolveGroupJoinRequest(i interface{}, accept bool) { +func (c *QQClient) SolveGroupJoinRequest(i interface{}, accept, block bool, reason string) { + if accept { + block = false + reason = "" + } + switch req := i.(type) { case *UserJoinGroupRequest: - _, pkt := c.buildSystemMsgGroupActionPacket(req.RequestId, req.RequesterUin, req.GroupCode, false, accept, false) + _, pkt := c.buildSystemMsgGroupActionPacket(req.RequestId, req.RequesterUin, req.GroupCode, false, accept, block, reason) _ = c.send(pkt) case *GroupInvitedRequest: - _, pkt := c.buildSystemMsgGroupActionPacket(req.RequestId, req.InvitorUin, req.GroupCode, true, accept, false) + _, pkt := c.buildSystemMsgGroupActionPacket(req.RequestId, req.InvitorUin, req.GroupCode, true, accept, block, reason) _ = c.send(pkt) } } diff --git a/client/entities.go b/client/entities.go index b2f4a37b..5b29b49a 100644 --- a/client/entities.go +++ b/client/entities.go @@ -267,19 +267,19 @@ func (m *GroupMemberInfo) Manageable() bool { } func (r *UserJoinGroupRequest) Accept() { - r.client.SolveGroupJoinRequest(r, true) + r.client.SolveGroupJoinRequest(r, true, false, "") } -func (r *UserJoinGroupRequest) Reject() { - r.client.SolveGroupJoinRequest(r, false) +func (r *UserJoinGroupRequest) Reject(block bool, reason string) { + r.client.SolveGroupJoinRequest(r, false, block, reason) } func (r *GroupInvitedRequest) Accept() { - r.client.SolveGroupJoinRequest(r, true) + r.client.SolveGroupJoinRequest(r, true, false, "") } -func (r *GroupInvitedRequest) Reject() { - r.client.SolveGroupJoinRequest(r, false) +func (r *GroupInvitedRequest) Reject(block bool, reason string) { + r.client.SolveGroupJoinRequest(r, false, block, reason) } func (r *NewFriendRequest) Accept() {