group_helper/cli/commands/list_verify.go

71 lines
1.7 KiB
Go

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"
)
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 listVerifyCommand struct {
verifyData *obj.VerifyData
}
func (w listVerifyCommand) GetUsage() string {
return "/verifylist"
}
func (w listVerifyCommand) GetCommand() string {
return "/verifylist"
}
func (w listVerifyCommand) GetDescription() string {
return "List all UserIDs that try to verify right now"
}
func (w listVerifyCommand) ExecuteCommand(api *tgbotapi.BotAPI, update *tgbotapi.Update, group *models.Group) (bool, error) {
currentUsers := make([]string, 0)
for _, user := range w.verifyData.Users {
if user.GroupID != group.GroupID {
continue
}
currentUsers = append(currentUsers, strconv.Itoa(user.UserID))
}
_, err := api.Send(tgbotapi.NewMessage(update.Message.Chat.ID, "Users: [" + strings.Join(currentUsers, ",") + "]"))
return err != nil, err
}
func (w listVerifyCommand) AllowChatType(chat *tgbotapi.Chat) bool {
return chat.IsGroup() || chat.IsSuperGroup()
}
func (w listVerifyCommand) AllowMember(member *tgbotapi.ChatMember) bool {
return member.IsAdministrator() || member.IsCreator()
}
func (w listVerifyCommand) AllowEveryMember() bool {
return false
}
func NewListVerifyCommand(verifyData *obj.VerifyData) cli.Command {
return &listVerifyCommand{
verifyData: verifyData,
}
}