Skip to content

Commit

Permalink
fix(bots): check is keyword on cooldown before sending messages and f…
Browse files Browse the repository at this point in the history
…ire event
  • Loading branch information
Satont committed Aug 26, 2023
1 parent d163582 commit 6d1d864
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/bots/internal/bots/handlers/message_keywods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6d1d864

Please sign in to comment.