diff --git a/telegram/routines/joinchecker.go b/telegram/routines/joinchecker.go index 91e10ed..0de7465 100644 --- a/telegram/routines/joinchecker.go +++ b/telegram/routines/joinchecker.go @@ -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, "💊") +}