mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
fix Mrs4s/go-cqhttp#121.
This commit is contained in:
parent
47d4fdde60
commit
60142c405d
@ -64,7 +64,6 @@ type QQClient struct {
|
|||||||
lastLostMsg string
|
lastLostMsg string
|
||||||
groupMsgBuilders sync.Map
|
groupMsgBuilders sync.Map
|
||||||
onlinePushCache []int16 // reset on reconnect
|
onlinePushCache []int16 // reset on reconnect
|
||||||
msgSvcCache *utils.Cache
|
|
||||||
requestPacketRequestId int32
|
requestPacketRequestId int32
|
||||||
groupSeq int32
|
groupSeq int32
|
||||||
friendSeq int32
|
friendSeq int32
|
||||||
@ -73,6 +72,7 @@ type QQClient struct {
|
|||||||
eventHandlers *eventHandlers
|
eventHandlers *eventHandlers
|
||||||
|
|
||||||
groupListLock *sync.Mutex
|
groupListLock *sync.Mutex
|
||||||
|
msgSvcLock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
type loginSigInfo struct {
|
type loginSigInfo struct {
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/pttcenter"
|
"github.com/Mrs4s/MiraiGo/client/pb/pttcenter"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -136,6 +135,8 @@ func decodePushReqPacket(c *QQClient, _ uint16, payload []byte) (interface{}, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func decodeMessageSvcPacket(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
func decodeMessageSvcPacket(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
||||||
|
c.msgSvcLock.Lock()
|
||||||
|
defer c.msgSvcLock.Unlock()
|
||||||
rsp := msg.GetMessageResponse{}
|
rsp := msg.GetMessageResponse{}
|
||||||
err := proto.Unmarshal(payload, &rsp)
|
err := proto.Unmarshal(payload, &rsp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -165,13 +166,9 @@ func decodeMessageSvcPacket(c *QQClient, _ uint16, payload []byte) (interface{},
|
|||||||
if message.Head.ToUin != c.Uin {
|
if message.Head.ToUin != c.Uin {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if message.Head.MsgType != 166 {
|
if (int64(pairMsg.LastReadTime) & 4294967295) > int64(message.Head.MsgTime) {
|
||||||
strSeq := strconv.FormatInt(int64(message.Head.MsgSeq), 10)
|
|
||||||
if _, ok := c.msgSvcCache.Get(strSeq); ok {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.msgSvcCache.Add(strSeq, 0, time.Minute*15)
|
|
||||||
}
|
|
||||||
switch message.Head.MsgType {
|
switch message.Head.MsgType {
|
||||||
case 33: // 加群同步
|
case 33: // 加群同步
|
||||||
groupJoinLock.Lock()
|
groupJoinLock.Lock()
|
||||||
@ -234,7 +231,8 @@ func decodeMessageSvcPacket(c *QQClient, _ uint16, payload []byte) (interface{},
|
|||||||
if message.Body.RichText == nil || message.Body.RichText.Elems == nil {
|
if message.Body.RichText == nil || message.Body.RichText.Elems == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
friend := c.FindFriend(message.Head.FromUin)
|
//friend := c.FindFriend(message.Head.FromUin)
|
||||||
|
/*
|
||||||
if friend == nil {
|
if friend == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
@ -246,6 +244,7 @@ func decodeMessageSvcPacket(c *QQClient, _ uint16, payload []byte) (interface{},
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
friend.msgSeqList.Add(strSeq, 0, time.Minute*15)
|
friend.msgSeqList.Add(strSeq, 0, time.Minute*15)
|
||||||
|
*/
|
||||||
c.dispatchFriendMessage(c.parsePrivateMessage(message))
|
c.dispatchFriendMessage(c.parsePrivateMessage(message))
|
||||||
case 187:
|
case 187:
|
||||||
_, pkt := c.buildSystemMsgNewFriendPacket()
|
_, pkt := c.buildSystemMsgNewFriendPacket()
|
||||||
@ -253,8 +252,7 @@ func decodeMessageSvcPacket(c *QQClient, _ uint16, payload []byte) (interface{},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, delPkt := c.buildDeleteMessageRequestPacket(delItems)
|
_, _ = c.sendAndWait(c.buildDeleteMessageRequestPacket(delItems))
|
||||||
_ = c.send(delPkt)
|
|
||||||
if rsp.SyncFlag != msg.SyncFlag_STOP {
|
if rsp.SyncFlag != msg.SyncFlag_STOP {
|
||||||
_, nextPkt := c.buildGetMessageRequestPacket(rsp.SyncFlag, time.Now().Unix())
|
_, nextPkt := c.buildGetMessageRequestPacket(rsp.SyncFlag, time.Now().Unix())
|
||||||
_ = c.send(nextPkt)
|
_ = c.send(nextPkt)
|
||||||
|
@ -2,7 +2,6 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/Mrs4s/MiraiGo/utils"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@ -37,7 +36,7 @@ type (
|
|||||||
Remark string
|
Remark string
|
||||||
FaceId int16
|
FaceId int16
|
||||||
|
|
||||||
msgSeqList *utils.Cache
|
//msgSeqList *utils.Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendListResponse struct {
|
FriendListResponse struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user