From 771de6ebea057c083d88e0d849ccaabe54616ef6 Mon Sep 17 00:00:00 2001 From: David Florness Date: Fri, 29 Oct 2021 22:51:00 -0400 Subject: [PATCH] Only respond to msgs that were sent in the last five minutes --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index bb5ad8f..f33289f 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "regexp" + "time" _ "github.com/mattn/go-sqlite3" @@ -136,6 +137,10 @@ func isBadEncryptError(err error) bool { // this function assumes evt.Type is EventMessage // return value is the body of the message to send back, if any func getMsgResponse(client *mautrix.Client, evt *event.Event) string { + // only respond to messages that were sent in the last five minutes + if time.Unix(evt.Timestamp / 1000, evt.Timestamp % 1000).Before(time.Now().Add(time.Minute * -5)) { + return "" + } content := evt.Content.AsMessage() if content.MsgType != event.MsgText { return "" -- 2.38.4