From 0136cb21d9cf1d656b2f687a10b969388bb95c88 Mon Sep 17 00:00:00 2001 From: Mrs4s <1844812067@qq.com> Date: Fri, 31 Jul 2020 12:15:25 +0800 Subject: [PATCH] add: group.Quit(). --- client/builders.go | 24 ++++++++++++++++++++++++ client/client.go | 4 ++++ client/entities.go | 6 ++++++ 3 files changed, 34 insertions(+) diff --git a/client/builders.go b/client/builders.go index d908b7a4..a85ea696 100644 --- a/client/builders.go +++ b/client/builders.go @@ -869,3 +869,27 @@ func (c *QQClient) buildMultiApplyDownPacket(resId string) (uint16, []byte) { packet := packets.BuildUniPacket(c.Uin, seq, "MultiMsg.ApplyDown", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) return seq, packet } + +// ProfileService.GroupMngReq +func (c *QQClient) buildQuitGroupPacket(groupCode int64) (uint16, []byte) { + seq := c.nextSeq() + jw := jce.NewJceWriter() + jw.WriteInt32(2, 0) + jw.WriteInt64(c.Uin, 1) + jw.WriteBytes(binary.NewWriterF(func(w *binary.Writer) { + w.WriteUInt32(uint32(c.Uin)) + w.WriteUInt32(uint32(groupCode)) + }), 2) + buf := &jce.RequestDataVersion3{Map: map[string][]byte{"GroupMngReq": packRequestDataV3(jw.Bytes())}} + pkt := &jce.RequestPacket{ + IVersion: 3, + IRequestId: c.nextPacketSeq(), + SServantName: "KQQ.ProfileService.ProfileServantObj", + SFuncName: "GroupMngReq", + SBuffer: buf.ToBytes(), + Context: map[string]string{}, + Status: map[string]string{}, + } + packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.GroupMngReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, pkt.ToBytes()) + return seq, packet +} diff --git a/client/client.go b/client/client.go index ea463958..3fce6687 100644 --- a/client/client.go +++ b/client/client.go @@ -584,6 +584,10 @@ func (c *QQClient) groupMute(groupCode, memberUin int64, time uint32) { _, _ = c.sendAndWait(c.buildGroupMutePacket(groupCode, memberUin, time)) } +func (c *QQClient) quitGroup(groupCode int64) { + _, _ = c.sendAndWait(c.buildQuitGroupPacket(groupCode)) +} + func (c *QQClient) kickGroupMember(groupCode, memberUin int64, msg string) { _, _ = c.sendAndWait(c.buildGroupKickPacket(groupCode, memberUin, msg)) } diff --git a/client/entities.go b/client/entities.go index 5ffca9bc..6597e943 100644 --- a/client/entities.go +++ b/client/entities.go @@ -188,6 +188,12 @@ func (g *GroupInfo) MuteAll(mute bool) { } } +func (g *GroupInfo) Quit() { + if g.SelfPermission() != Owner { + g.client.quitGroup(g.Code) + } +} + func (m *GroupMemberInfo) DisplayName() string { if m.CardName == "" { return m.Nickname