diff --git a/client/builders.go b/client/builders.go index 6263a555..16a2507d 100644 --- a/client/builders.go +++ b/client/builders.go @@ -6,6 +6,8 @@ import ( "math/rand" "strconv" + "github.com/golang/protobuf/proto" + "github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/binary/jce" "github.com/Mrs4s/MiraiGo/client/pb" @@ -20,7 +22,6 @@ import ( "github.com/Mrs4s/MiraiGo/protocol/packets" "github.com/Mrs4s/MiraiGo/protocol/tlv" "github.com/Mrs4s/MiraiGo/utils" - "github.com/golang/protobuf/proto" ) var ( @@ -846,6 +847,16 @@ func (c *QQClient) buildGroupNameUpdatePacket(groupCode int64, newName string) ( return c.buildGroupOperationPacket(body) } +func (c *QQClient) buildGroupMemoUpdatePacket(groupCode int64, newMemo string) (uint16, []byte) { + body := &oidb.D89AReqBody{ + GroupCode: groupCode, + StGroupInfo: &oidb.D89AGroupinfo{ + IngGroupMemo: []byte(newMemo), + }, + } + return c.buildGroupOperationPacket(body) +} + // OidbSvc.0x89a_0 func (c *QQClient) buildGroupMuteAllPacket(groupCode int64, mute bool) (uint16, []byte) { body := &oidb.D89AReqBody{ diff --git a/client/client.go b/client/client.go index 042dcaad..4ce88c1c 100644 --- a/client/client.go +++ b/client/client.go @@ -16,6 +16,8 @@ import ( "sync/atomic" "time" + "github.com/golang/protobuf/proto" + "github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/client/pb/longmsg" "github.com/Mrs4s/MiraiGo/client/pb/msg" @@ -23,7 +25,6 @@ import ( "github.com/Mrs4s/MiraiGo/message" "github.com/Mrs4s/MiraiGo/protocol/packets" "github.com/Mrs4s/MiraiGo/utils" - "github.com/golang/protobuf/proto" ) type QQClient struct { @@ -754,6 +755,10 @@ func (c *QQClient) updateGroupName(groupCode int64, newName string) { _, _ = c.sendAndWait(c.buildGroupNameUpdatePacket(groupCode, newName)) } +func (c *QQClient) updateGroupMemo(groupCode int64, newMemo string) { + _, _ = c.sendAndWait(c.buildGroupMemoUpdatePacket(groupCode, newMemo)) +} + func (c *QQClient) groupMuteAll(groupCode int64, mute bool) { _, _ = c.sendAndWait(c.buildGroupMuteAllPacket(groupCode, mute)) } diff --git a/client/entities.go b/client/entities.go index 582ebdf9..6b8456e2 100644 --- a/client/entities.go +++ b/client/entities.go @@ -208,6 +208,13 @@ func (g *GroupInfo) UpdateName(newName string) { } } +func (g *GroupInfo) UpdateMemo(newMemo string) { + if g.AdministratorOrOwner() { + g.client.updateGroupMemo(g.Code, newMemo) + g.Memo = newMemo + } +} + func (g *GroupInfo) MuteAll(mute bool) { if g.AdministratorOrOwner() { g.client.groupMuteAll(g.Code, mute)