package commands import ( "git.dragon-labs.de/alphyron/group_helper/cli" "git.dragon-labs.de/alphyron/group_helper/models" "git.dragon-labs.de/alphyron/group_helper/obj" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" "strconv" "strings" ) type whitelistCommand struct { verifyData *obj.VerifyData } func (w whitelistCommand) GetUsage() string { return "/whitelist [user_id]" } func (w whitelistCommand) GetCommand() string { return "/whitelist" } func (w whitelistCommand) GetDescription() string { return "Whitelist an given User so the bot cancel the JOIN Validation" } func (w whitelistCommand) ExecuteCommand(api *tgbotapi.BotAPI, update *tgbotapi.Update, group *models.Group) (bool, error) { message := update.Message.Text parts := strings.Split(message, " ") if len(parts) == 1 { _, err := api.Send(tgbotapi.NewMessage(update.Message.Chat.ID, "Wrong usage of this Command:\n"+w.GetUsage())) return err != nil, err } userID, err := strconv.Atoi(parts[1]) if err != nil { _, err := api.Send(tgbotapi.NewMessage(update.Message.Chat.ID, "Please provide an integer as ID:\n"+w.GetUsage())) return err != nil, err } w.verifyData.RemoveUser(userID, group.GroupID) _, err = api.Send(tgbotapi.NewMessage(update.Message.Chat.ID, "User is free :D")) return err != nil, err } func (w whitelistCommand) AllowChatType(chat *tgbotapi.Chat) bool { return chat.IsGroup() || chat.IsSuperGroup() } func (w whitelistCommand) AllowMember(member *tgbotapi.ChatMember) bool { return member.IsAdministrator() || member.IsCreator() } func (w whitelistCommand) AllowEveryMember() bool { return false } func NewWhitelistCommand(verifyData *obj.VerifyData) cli.Command { return &whitelistCommand{ verifyData: verifyData, } }