1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00
This commit is contained in:
Mrs4s 2020-07-24 22:41:26 +08:00
parent bb7099dbd7
commit 1561cf25a4
4 changed files with 18 additions and 8 deletions

View File

@ -18,7 +18,7 @@ qq-android协议的golang实现 移植于Mirai
- [x] At
- [x] 回复
- [ ] 长消息
- [x] 合并转发
- [x] 合并转发(有待测试)
#### 事件
- [x] 好友消息

View File

@ -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),

View File

@ -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() {

View File

@ -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,
},
},