increase spam messages limit

This commit is contained in:
unintendedfraud
2024-04-25 20:56:00 +02:00
parent 7c2099262f
commit 1f2411b6bf
+8 -6
View File
@@ -2,18 +2,22 @@ package handlers
import ( import (
"fmt" "fmt"
"hal/openai"
"log" "log"
"math/rand" "math/rand"
"regexp" "regexp"
"time" "time"
"hal/openai"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
) )
const MAX_HISTORY = 50 const MAX_HISTORY = 50
const SPAM_PERIOD = 5 * time.Minute const (
SPAM_PERIOD = 5 * time.Minute
MESSAGES_PER_PERIOD = 10
)
var spams = []string{ var spams = []string{
":GroGroDebile:", ":GroGroDebile:",
@@ -57,9 +61,7 @@ func (h Handler) OnMessageCreated(s *discordgo.Session, m *discordgo.MessageCrea
return return
} }
var userSpamTooMuch bool userSpamTooMuch := updateUserHistoryCount(m.Author.ID)
userSpamTooMuch = updateUserHistoryCount(m.Author.ID)
if userSpamTooMuch { if userSpamTooMuch {
sendResponse(s, m.ChannelID, getRandomSpam()) sendResponse(s, m.ChannelID, getRandomSpam())
@@ -157,7 +159,7 @@ func updateUserHistoryCount(userID string) bool {
return false return false
} }
if u.count > 2 { if u.count > MESSAGES_PER_PERIOD {
u.bannedUntilAt = now.Add(30 * time.Minute) u.bannedUntilAt = now.Add(30 * time.Minute)
return true return true
} }