Don't respond if message is older than 5 mins

This commit is contained in:
Sangeeth Sudheer 2025-04-12 13:52:41 +05:30
parent 380b9bb7dd
commit 3e63694be3
Signed by: x
GPG Key ID: F6D06ECE734C57D1

View File

@ -167,6 +167,11 @@ func (client *Client) eventHandler(evt interface{}) {
return
}
if time.Now().Sub(v.Info.Timestamp).Minutes() >= 5 {
fmt.Printf("Message from %s older than 5 minutes, skipping\n", chatUserId)
return
}
time.Sleep(2 * time.Duration(rand.IntN(3)) * time.Second)
client.WAClient.SendChatPresence(v.Info.Chat, types.ChatPresenceComposing, types.ChatPresenceMediaText)