From 6d1d864988abe0ba92721e21a6cabc620c8f6fdb Mon Sep 17 00:00:00 2001 From: Satont Date: Sat, 26 Aug 2023 09:25:53 +0300 Subject: [PATCH] fix(bots): check is keyword on cooldown before sending messages and fire event --- apps/bots/internal/bots/handlers/message_keywods.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/bots/internal/bots/handlers/message_keywods.go b/apps/bots/internal/bots/handlers/message_keywods.go index 43877aa4b..192d348b4 100644 --- a/apps/bots/internal/bots/handlers/message_keywods.go +++ b/apps/bots/internal/bots/handlers/message_keywods.go @@ -76,10 +76,14 @@ func (c *Handlers) handleKeywords( isOnCooldown = k.CooldownExpireAt.Time.After(time.Now().UTC()) } + if isOnCooldown { + return + } + query := make(map[string]any) var responses []string - if !isOnCooldown && k.Response != "" { + if k.Response != "" { requestStruct := &parser.ParseTextRequestData{ Channel: &parser.Channel{ Id: msg.Channel.ID, @@ -111,7 +115,8 @@ func (c *Handlers) handleKeywords( } _, err = c.eventsGrpc.KeywordMatched( - context.Background(), &events.KeywordMatchedMessage{ + context.Background(), + &events.KeywordMatchedMessage{ BaseInfo: &events.BaseInfo{ChannelId: msg.Channel.ID}, KeywordId: k.ID, KeywordName: k.Text,