mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
supported group message recall.
This commit is contained in:
parent
a45ad2e147
commit
3d59f00d15
@ -14,6 +14,7 @@ func ZlibUncompress(src []byte) []byte {
|
||||
b := bytes.NewReader(src)
|
||||
var out bytes.Buffer
|
||||
r, _ := zlib.NewReader(b)
|
||||
defer r.Close()
|
||||
io.Copy(&out, r)
|
||||
return out.Bytes()
|
||||
}
|
||||
|
@ -586,6 +586,30 @@ func (c *QQClient) buildSystemMsgFriendActionPacket(reqId, requester int64, acce
|
||||
return seq, packet
|
||||
}
|
||||
|
||||
// PbMessageSvc.PbMsgWithDraw
|
||||
func (c *QQClient) buildGroupRecallPacket(groupCode int64, msgSeq, msgRan int32) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
req := &msg.MsgWithDrawReq{
|
||||
GroupWithDraw: []*msg.GroupMsgWithDrawReq{
|
||||
{
|
||||
SubCmd: 1,
|
||||
GroupCode: groupCode,
|
||||
MsgList: []*msg.GroupMsgInfo{
|
||||
{
|
||||
MsgSeq: msgSeq,
|
||||
MsgRandom: msgRan,
|
||||
MsgType: 0,
|
||||
},
|
||||
},
|
||||
UserDef: []byte{0x08, 0x00},
|
||||
},
|
||||
},
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
packet := packets.BuildUniPacket(c.Uin, seq, "PbMessageSvc.PbMsgWithDraw", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
|
||||
return seq, packet
|
||||
}
|
||||
|
||||
/*
|
||||
func (c *QQClient) buildMultiMsgDownRequestPacket() (uint16, []byte){
|
||||
seq := c.nextSeq()
|
||||
|
@ -192,26 +192,43 @@ func (c *QQClient) GetFriendList() (*FriendListResponse, error) {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (c *QQClient) SendGroupMessage(groupCode int64, m *message.SendingMessage) int32 {
|
||||
func (c *QQClient) SendGroupMessage(groupCode int64, m *message.SendingMessage) *message.GroupMessage {
|
||||
eid := utils.RandomString(6)
|
||||
mr := int32(rand.Uint32())
|
||||
ch := make(chan int32)
|
||||
c.onGroupMessageReceipt(eid, func(c *QQClient, e *groupMessageReceiptEvent) {
|
||||
if e.Rand == mr {
|
||||
ch <- e.Seq
|
||||
c.onGroupMessageReceipt(eid)
|
||||
}
|
||||
})
|
||||
defer c.onGroupMessageReceipt(eid)
|
||||
_, pkt := c.buildGroupSendingPacket(groupCode, mr, m)
|
||||
_ = c.send(pkt)
|
||||
var mid int32
|
||||
ret := &message.GroupMessage{
|
||||
Id: -1,
|
||||
InternalId: mr,
|
||||
GroupCode: groupCode,
|
||||
Sender: &message.Sender{
|
||||
Uin: c.Uin,
|
||||
Nickname: c.Nickname,
|
||||
IsFriend: true,
|
||||
},
|
||||
Time: int32(time.Now().Unix()),
|
||||
Elements: m.Elements,
|
||||
}
|
||||
select {
|
||||
case mid = <-ch:
|
||||
case <-time.After(time.Second * 5):
|
||||
c.onGroupMessageReceipt(eid)
|
||||
return -1
|
||||
return ret
|
||||
}
|
||||
return mid
|
||||
ret.Id = mid
|
||||
return ret
|
||||
}
|
||||
|
||||
func (c *QQClient) RecallGroupMessage(groupCode int64, msgId, msgInternalId int32) {
|
||||
_, pkt := c.buildGroupRecallPacket(groupCode, msgId, msgInternalId)
|
||||
_ = c.send(pkt)
|
||||
}
|
||||
|
||||
func (c *QQClient) UploadGroupImage(groupCode int64, img []byte) (*message.GroupImageElement, error) {
|
||||
|
@ -248,6 +248,9 @@ func (c *QQClient) parseGroupMessage(m *msg.Message) *message.GroupMessage {
|
||||
Elements: message.ParseMessageElems(m.Body.RichText.Elems),
|
||||
//OriginalElements: m.Body.RichText.Elems,
|
||||
}
|
||||
if m.Body.RichText.Attr != nil {
|
||||
g.InternalId = m.Body.RichText.Attr.Random
|
||||
}
|
||||
return g
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -35,6 +35,46 @@ message SendMessageRequest {
|
||||
|
||||
}
|
||||
|
||||
message MsgWithDrawReq {
|
||||
repeated C2CMsgWithDrawReq c2cWithDraw = 1;
|
||||
repeated GroupMsgWithDrawReq groupWithDraw = 2;
|
||||
}
|
||||
|
||||
message C2CMsgWithDrawReq{
|
||||
repeated C2CMsgInfo msgInfo = 1;
|
||||
int32 longMessageFlag = 2;
|
||||
bytes reserved = 3;
|
||||
int32 subCmd = 4;
|
||||
}
|
||||
|
||||
message GroupMsgWithDrawReq{
|
||||
int32 subCmd = 1;
|
||||
int32 groupType = 2;
|
||||
int64 groupCode = 3;
|
||||
repeated GroupMsgInfo msgList = 4;
|
||||
bytes userDef = 5;
|
||||
}
|
||||
|
||||
message GroupMsgInfo {
|
||||
int32 msgSeq = 1;
|
||||
int32 msgRandom = 2;
|
||||
int32 msgType = 3;
|
||||
}
|
||||
|
||||
message C2CMsgInfo {
|
||||
int64 fromUin = 1;
|
||||
int64 toUin = 2;
|
||||
int32 msgSeq = 3;
|
||||
int64 msgUid = 4;
|
||||
int64 msgTime = 5;
|
||||
int32 msgRandom = 6;
|
||||
int32 pkgNum = 7;
|
||||
int32 pkgIndex = 8;
|
||||
int32 divSeq = 9;
|
||||
int32 msgType = 10;
|
||||
RoutingHead routingHead = 20;
|
||||
}
|
||||
|
||||
message RoutingHead {
|
||||
C2C c2c = 1;
|
||||
Grp grp = 2;
|
||||
|
@ -22,12 +22,13 @@ type TempMessage struct {
|
||||
}
|
||||
|
||||
type GroupMessage struct {
|
||||
Id int32
|
||||
GroupCode int64
|
||||
GroupName string
|
||||
Sender *Sender
|
||||
Time int32
|
||||
Elements []IMessageElement
|
||||
Id int32
|
||||
InternalId int32
|
||||
GroupCode int64
|
||||
GroupName string
|
||||
Sender *Sender
|
||||
Time int32
|
||||
Elements []IMessageElement
|
||||
//OriginalElements []*msg.Elem
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user