From 8f0cd9494d647aa1739a2acf9ef10daa814ec253 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Tue, 25 May 2021 09:01:01 +0800 Subject: [PATCH] filter c2c msg by time. --- client/c2c_processor.go | 5 +++++ client/client.go | 1 + 2 files changed, 6 insertions(+) diff --git a/client/c2c_processor.go b/client/c2c_processor.go index 4c924860..5e67fc74 100644 --- a/client/c2c_processor.go +++ b/client/c2c_processor.go @@ -119,6 +119,11 @@ func (c *QQClient) commMsgProcessor(pMsg *msg.Message, info *incomingPacketInfo) return } c.msgSvcCache.Add(strKey, "", time.Hour) + if c.lastC2CMsgTime > int64(pMsg.Head.GetMsgTime()) && (c.lastC2CMsgTime-int64(pMsg.Head.GetMsgTime())) > 60*10 { + c.Debug("c2c msg filtered by time. lastMsgTime: %v msgTime: %v", c.lastC2CMsgTime, pMsg.Head.GetMsgTime()) + return + } + c.lastC2CMsgTime = int64(pMsg.Head.GetMsgTime()) if info.Params.bool("init") { return } diff --git a/client/client.go b/client/client.go index 3f1b2b46..e7a3fef1 100644 --- a/client/client.go +++ b/client/client.go @@ -85,6 +85,7 @@ type QQClient struct { lastMessageSeq int32 // lastMessageSeqTmp sync.Map msgSvcCache *utils.Cache + lastC2CMsgTime int64 transCache *utils.Cache lastLostMsg string groupSysMsgCache *GroupSystemMessages