s
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
const MAX_HISTORY = 50
|
const MAX_HISTORY = 50
|
||||||
|
|
||||||
const SPAM_PERIOD = 5 * time.Minute
|
const SPAM_PERIOD = 1 * time.Minute
|
||||||
|
|
||||||
var spams = []string{
|
var spams = []string{
|
||||||
":GroGroDebile:",
|
":GroGroDebile:",
|
||||||
@@ -63,6 +63,7 @@ func (h Handler) OnMessageCreated(s *discordgo.Session, m *discordgo.MessageCrea
|
|||||||
|
|
||||||
if userSpamTooMuch {
|
if userSpamTooMuch {
|
||||||
sendResponse(s, m.ChannelID, getRandomSpam())
|
sendResponse(s, m.ChannelID, getRandomSpam())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for id, u := range usersHistoryCount {
|
for id, u := range usersHistoryCount {
|
||||||
@@ -135,7 +136,6 @@ func updateUserHistoryCount(userID string) bool {
|
|||||||
|
|
||||||
u, ok := usersHistoryCount[userID]
|
u, ok := usersHistoryCount[userID]
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Println("user does not exist")
|
|
||||||
usersHistoryCount[userID] = &userHistoryCount{
|
usersHistoryCount[userID] = &userHistoryCount{
|
||||||
date: now,
|
date: now,
|
||||||
count: 1,
|
count: 1,
|
||||||
@@ -152,16 +152,16 @@ func updateUserHistoryCount(userID string) bool {
|
|||||||
|
|
||||||
if !u.bannedUntilAt.IsZero() {
|
if !u.bannedUntilAt.IsZero() {
|
||||||
u.bannedUntilAt = time.Time{}
|
u.bannedUntilAt = time.Time{}
|
||||||
|
u.count = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if u.date.Add(SPAM_PERIOD).Before(now) {
|
if u.date.Add(SPAM_PERIOD).Before(now) {
|
||||||
fmt.Println("date after spam period")
|
|
||||||
u.count = 1
|
u.count = 1
|
||||||
u.date = now
|
u.date = now
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if u.count > 5 {
|
if u.count > 2 {
|
||||||
u.bannedUntilAt = now.Add(2 * time.Minute)
|
u.bannedUntilAt = now.Add(2 * time.Minute)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user