package commands import ( "fmt" "git.dragon-labs.de/alphyron/group_helper/cli" "git.dragon-labs.de/alphyron/group_helper/models" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" "log" ) type helpCommand struct { commandManager *cli.CommandManager } func NewHelpCommand(commandManager *cli.CommandManager) cli.Command { return &helpCommand{commandManager: commandManager} } func (h helpCommand) GetUsage() string { return "/help" } func (h helpCommand) GetCommand() string { return "/help" } func (h helpCommand) GetDescription() string { return "Information about all commands" } func (h helpCommand) ExecuteCommand(bot *tgbotapi.BotAPI, update *tgbotapi.Update, group *models.Group) (bool, error) { log.Println("test1") messages := "All supported Commands:" for _, cmd := range h.commandManager.Commands { messages += fmt.Sprintf("\n%s - %s", cmd.GetUsage(), cmd.GetDescription()) } msg := tgbotapi.NewMessage(update.Message.Chat.ID, messages) msg.ParseMode = "Markdown" _, err := bot.Send(msg) return err == nil, err } func (h helpCommand) AllowChatType(_ *tgbotapi.Chat) bool { return true } func (h helpCommand) AllowMember(_ *tgbotapi.ChatMember) bool { return true } func (h helpCommand) AllowEveryMember() bool { return true }