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-08-17 23:32:46 +08:00
parent 47d4fdde60
commit 60142c405d
3 changed files with 21 additions and 24 deletions

View File

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

View File

@ -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,12 +166,8 @@ 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) continue
if _, ok := c.msgSvcCache.Get(strSeq); ok {
continue
}
c.msgSvcCache.Add(strSeq, 0, time.Minute*15)
} }
switch message.Head.MsgType { switch message.Head.MsgType {
case 33: // 加群同步 case 33: // 加群同步
@ -234,18 +231,20 @@ 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 { /*
return nil, nil if friend == nil {
} return nil, nil
if friend.msgSeqList == nil { }
friend.msgSeqList = utils.NewCache(time.Second * 5) if friend.msgSeqList == nil {
} friend.msgSeqList = utils.NewCache(time.Second * 5)
strSeq := strconv.FormatInt(int64(message.Head.MsgSeq), 10) }
if _, ok := friend.msgSeqList.Get(strSeq); ok { strSeq := strconv.FormatInt(int64(message.Head.MsgSeq), 10)
continue if _, ok := friend.msgSeqList.Get(strSeq); ok {
} 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)

View File

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