2024-10-28 20:39:17 +00:00
|
|
|
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))
|
|
|
|
}
|
|
|
|
|
2024-10-28 20:43:47 +00:00
|
|
|
_, err := api.Send(tgbotapi.NewMessage(update.Message.Chat.ID, "Users: ["+strings.Join(currentUsers, ",")+"]"))
|
2024-10-28 20:39:17 +00:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|