From f2b432a0cc1c0d6a56e899d679fc681ba6e10d12 Mon Sep 17 00:00:00 2001 From: Lennard Brinkhaus Date: Mon, 28 Oct 2024 21:10:58 +0100 Subject: [PATCH] feat: ban user with drug names --- telegram/routines/joinchecker.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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, "💊") +}