2020-05-16 19:27:45 +00:00
|
|
|
|
package routines
|
|
|
|
|
|
|
|
|
|
import (
|
2020-06-27 16:38:59 +00:00
|
|
|
|
message2 "git.dragon-labs.de/alphyron/group_helper/message"
|
2020-05-16 19:27:45 +00:00
|
|
|
|
"git.dragon-labs.de/alphyron/group_helper/models"
|
2020-06-08 20:12:36 +00:00
|
|
|
|
"git.dragon-labs.de/alphyron/group_helper/obj"
|
2020-05-16 19:27:45 +00:00
|
|
|
|
"git.dragon-labs.de/alphyron/group_helper/telegram"
|
|
|
|
|
"git.dragon-labs.de/alphyron/group_helper/util"
|
|
|
|
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
|
|
|
|
|
"log"
|
|
|
|
|
"math/rand"
|
|
|
|
|
"strconv"
|
2024-10-28 20:10:58 +00:00
|
|
|
|
"strings"
|
2020-05-16 19:27:45 +00:00
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type joinCheckerRoutine struct {
|
2020-06-08 20:12:36 +00:00
|
|
|
|
verifyData *obj.VerifyData
|
2020-05-16 19:27:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 20:12:36 +00:00
|
|
|
|
func NewJoinCheckerRoutine(verifyData *obj.VerifyData) telegram.Routine {
|
|
|
|
|
return joinCheckerRoutine{
|
|
|
|
|
verifyData: verifyData,
|
|
|
|
|
}
|
2020-05-16 19:27:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (j joinCheckerRoutine) Update(botAPI *tgbotapi.BotAPI, update *tgbotapi.Update, group *models.Group) error {
|
|
|
|
|
|
|
|
|
|
if update.Message == nil { // ignore any non-Message Updates
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if update.Message.Chat.IsPrivate() || update.Message.Chat.IsChannel() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if update.Message.NewChatMembers != nil {
|
|
|
|
|
for _, newUser := range *update.Message.NewChatMembers {
|
2020-12-15 23:06:13 +00:00
|
|
|
|
|
|
|
|
|
if newUser.IsBot {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-28 20:10:58 +00:00
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-13 18:26:15 +00:00
|
|
|
|
length := 3
|
2020-05-16 19:27:45 +00:00
|
|
|
|
|
|
|
|
|
tasks := make([][]tgbotapi.InlineKeyboardButton, length)
|
|
|
|
|
|
|
|
|
|
for i := 0; i < length; i++ {
|
|
|
|
|
tasks[i] = tgbotapi.NewInlineKeyboardRow(tgbotapi.NewInlineKeyboardButtonData(util.GenerateCalculation(i == 0), "UserValidation: "+strconv.FormatBool(i == 0)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
|
rand.Shuffle(len(tasks), func(i, j int) { tasks[i], tasks[j] = tasks[j], tasks[i] })
|
|
|
|
|
|
|
|
|
|
markup := tgbotapi.NewInlineKeyboardMarkup(tasks...)
|
|
|
|
|
|
2021-08-07 18:02:34 +00:00
|
|
|
|
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message2.ReplaceMessage(group.UserJoinMessage, &newUser, group))
|
2020-05-16 19:27:45 +00:00
|
|
|
|
msg.ParseMode = "Markdown"
|
|
|
|
|
msg.ReplyMarkup = markup
|
|
|
|
|
|
2020-06-08 20:12:36 +00:00
|
|
|
|
message, err := botAPI.Send(msg)
|
2020-05-16 19:27:45 +00:00
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Println("Problem to send verified Messages to user")
|
|
|
|
|
log.Println(newUser.FirstName)
|
|
|
|
|
log.Println(err)
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 20:12:36 +00:00
|
|
|
|
j.verifyData.AddUser(&obj.VerifyUser{
|
|
|
|
|
UserID: newUser.ID,
|
|
|
|
|
GroupID: group.GroupID,
|
|
|
|
|
LeftTime: group.KickCooldown,
|
|
|
|
|
MessageID: message.MessageID,
|
|
|
|
|
})
|
2020-05-16 19:27:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2024-10-28 20:10:58 +00:00
|
|
|
|
|
|
|
|
|
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, "😘") ||
|
2024-11-15 20:10:09 +00:00
|
|
|
|
strings.Contains(name, "𝗗𝗘𝗔𝗟𝗘𝗥") ||
|
|
|
|
|
strings.Contains(name, "𝗪𝗘𝗘𝗗") ||
|
|
|
|
|
strings.Contains(name, "🥰") ||
|
|
|
|
|
strings.Contains(name, "😍") ||
|
|
|
|
|
strings.Contains(name, "COKE") ||
|
|
|
|
|
strings.Contains(name, "💊") ||
|
|
|
|
|
strings.Contains(name, "KOKA") ||
|
|
|
|
|
strings.Contains(name, "WEED") ||
|
2024-10-28 20:10:58 +00:00
|
|
|
|
strings.Contains(name, "💊")
|
|
|
|
|
}
|