mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-08 21:15:57 +08:00
feat set group essence msg
This commit is contained in:
parent
576af530d5
commit
5bc04f7123
@ -22,6 +22,7 @@ func init() {
|
|||||||
decoders["MessageSvc.PbSendMsg"] = decodeMsgSendResponse
|
decoders["MessageSvc.PbSendMsg"] = decodeMsgSendResponse
|
||||||
decoders["MessageSvc.PbGetGroupMsg"] = decodeGetGroupMsgResponse
|
decoders["MessageSvc.PbGetGroupMsg"] = decodeGetGroupMsgResponse
|
||||||
decoders["OidbSvc.0x8a7_0"] = decodeAtAllRemainResponse
|
decoders["OidbSvc.0x8a7_0"] = decodeAtAllRemainResponse
|
||||||
|
decoders["OidbSvc.0xeac_1"] = decodeEssenceMsgResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendGroupMessage 发送群消息
|
// SendGroupMessage 发送群消息
|
||||||
@ -520,3 +521,40 @@ func (c *QQClient) parseGroupMessage(m *msg.Message) *message.GroupMessage {
|
|||||||
}
|
}
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetEssenceMessage 设置群精华消息
|
||||||
|
func (c *QQClient) SetEssenceMessage(groupCode int64, msgId, msgInternalId int32) error {
|
||||||
|
r, err := c.sendAndWait(c.buildSetEssenceMsgPacket(groupCode, uint32(msgId), uint32(msgInternalId)))
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "set essence msg network:")
|
||||||
|
}
|
||||||
|
rsp := r.(*oidb.EACRspBody)
|
||||||
|
if rsp.GetErrorCode() != 0 {
|
||||||
|
return errors.New(rsp.GetWording())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *QQClient) buildSetEssenceMsgPacket(groupCode int64, msgSeq, msgRand uint32) (uint16, []byte) {
|
||||||
|
seq := c.nextSeq()
|
||||||
|
payload := c.packOIDBPackageProto(3756, 1, &oidb.EACReqBody{ // serviceType 2 取消
|
||||||
|
GroupCode: proto.Uint64(uint64(groupCode)),
|
||||||
|
Seq: proto.Uint32(msgSeq),
|
||||||
|
Random: proto.Uint32(msgRand),
|
||||||
|
})
|
||||||
|
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xeac_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
|
||||||
|
return seq, packet
|
||||||
|
}
|
||||||
|
|
||||||
|
// OidbSvc.0xeac_1
|
||||||
|
func decodeEssenceMsgResponse(_ *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
||||||
|
pkg := oidb.OIDBSSOPkg{}
|
||||||
|
rsp := &oidb.EACRspBody{}
|
||||||
|
if err := proto.Unmarshal(payload, &pkg); err != nil {
|
||||||
|
return nil, errors.Wrap(err, "failed to unmarshal protobuf message")
|
||||||
|
}
|
||||||
|
if err := proto.Unmarshal(pkg.Bodybuffer, rsp); err != nil {
|
||||||
|
return nil, errors.Wrap(err, "failed to unmarshal protobuf message")
|
||||||
|
}
|
||||||
|
return rsp, nil
|
||||||
|
}
|
||||||
|
1
go.mod
1
go.mod
@ -5,6 +5,7 @@ go 1.15
|
|||||||
require (
|
require (
|
||||||
github.com/golang/protobuf v1.4.3
|
github.com/golang/protobuf v1.4.3
|
||||||
github.com/json-iterator/go v1.1.10
|
github.com/json-iterator/go v1.1.10
|
||||||
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
google.golang.org/protobuf v1.25.0
|
google.golang.org/protobuf v1.25.0
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user