feat: ban user with drug names

This commit is contained in:
Lennard Brinkhaus 2024-10-28 21:10:58 +01:00
parent a331374bbb
commit f2b432a0cc

View File

@ -10,6 +10,7 @@ import (
"log"
"math/rand"
"strconv"
"strings"
"time"
)
@ -40,6 +41,19 @@ func (j joinCheckerRoutine) Update(botAPI *tgbotapi.BotAPI, update *tgbotapi.Upd
continue
}
if hasDrugNames(strings.ToLower(newUser.FirstName)) ||
hasDrugNames(strings.ToLower(newUser.LastName)) ||
hasDrugNames(strings.ToLower(newUser.UserName)) {
botAPI.KickChatMember(tgbotapi.KickChatMemberConfig{
ChatMemberConfig: tgbotapi.ChatMemberConfig{
ChatID: update.Message.Chat.ID,
UserID: newUser.ID,
},
})
botAPI.DeleteMessage(tgbotapi.NewDeleteMessage(group.GroupID, update.Message.MessageID))
return nil
}
length := 3
tasks := make([][]tgbotapi.InlineKeyboardButton, length)
@ -75,3 +89,12 @@ func (j joinCheckerRoutine) Update(botAPI *tgbotapi.BotAPI, update *tgbotapi.Upd
}
return nil
}
func hasDrugNames(name string) bool {
return strings.Contains(name, "weed") ||
strings.Contains(name, "viagra") ||
strings.Contains(name, "mdma") ||
strings.Contains(name, "xanax") ||
strings.Contains(name, "😘") ||
strings.Contains(name, "💊")
}