diff --git a/README.md b/README.md index 05f58871..3314a2fa 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ qq-android协议的golang实现 移植于Mirai - [x] At - [x] 回复 - [ ] 长消息 -- [x] 合并转发 +- [x] 合并转发(有待测试) #### 事件 - [x] 好友消息 diff --git a/binary/utils.go b/binary/utils.go index 06db333d..51b5bfdf 100644 --- a/binary/utils.go +++ b/binary/utils.go @@ -32,10 +32,19 @@ func GZipCompress(data []byte) []byte { buf := new(bytes.Buffer) w := gzip.NewWriter(buf) _, _ = w.Write(data) - w.Close() + _ = w.Close() return buf.Bytes() } +func GZipUncompress(src []byte) []byte { + b := bytes.NewReader(src) + var out bytes.Buffer + r, _ := gzip.NewReader(b) + defer r.Close() + _, _ = io.Copy(&out, r) + return out.Bytes() +} + func CalculateImageResourceId(md5 []byte) string { return strings.ToUpper(fmt.Sprintf( "{%s}.png", GenUUID(md5), diff --git a/client/client.go b/client/client.go index bfa19cc7..cea4dd02 100644 --- a/client/client.go +++ b/client/client.go @@ -257,16 +257,15 @@ func (c *QQClient) SendPrivateMessage(target int64, m *message.SendingMessage) * } } -// TODO: Need fix +// 目前似乎iOS端无法正常打开转发消息,经测试数据上传正常,应该是解析问题。iOS目前没有越狱设备抓不到日志,有空再测试。 func (c *QQClient) SendForwardMessage(groupCode int64, m *message.ForwardMessage) *message.GroupMessage { if len(m.Nodes) >= 200 { return nil } - group := c.FindGroup(groupCode) ts := time.Now().Unix() seq := c.nextGroupSeq() data, hash := m.CalculateValidationData(seq, rand.Int31(), groupCode) - i, err := c.sendAndWait(c.buildMultiApplyUpPacket(data, hash, group.Uin)) + i, err := c.sendAndWait(c.buildMultiApplyUpPacket(data, hash, utils.ToGroupUin(groupCode))) if err != nil { return nil } @@ -278,7 +277,7 @@ func (c *QQClient) SendForwardMessage(groupCode int64, m *message.ForwardMessage MsgUpReq: []*longmsg.LongMsgUpReq{ { MsgType: 3, - DstUin: group.Uin, + DstUin: utils.ToGroupUin(groupCode), MsgContent: data, StoreType: 2, MsgUkey: rsp.MsgUkey, @@ -674,7 +673,7 @@ func (c *QQClient) loop() { } }() } - c.Conn.Close() + _ = c.Conn.Close() } func (c *QQClient) heartbeat() { diff --git a/message/message.go b/message/message.go index 7d1ae400..672ed1c7 100644 --- a/message/message.go +++ b/message/message.go @@ -352,13 +352,15 @@ func (forMsg *ForwardMessage) CalculateValidationData(seq, random int32, groupCo FromUin: node.SenderId, MsgSeq: seq, MsgTime: node.Time, - MsgUid: 0x01000000000000000 | int64(random), + MsgUid: 0x01000000000000000 | (int64(random) & 0xFFFF_FFFF), MutiltransHead: &msg.MutilTransHead{ MsgId: 1, }, MsgType: 82, GroupInfo: &msg.GroupInfo{ GroupCode: groupCode, + GroupRank: []byte{}, + GroupName: []byte{}, GroupCard: node.SenderName, }, },