30 lines
600 B
Go

package commands
import (
"strings"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
type HelpCommand struct{}
func (h HelpCommand) Name() string {
return "help"
}
func (h HelpCommand) Help() string {
return "Shows available commands."
}
func (h HelpCommand) Execute(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
var helpText strings.Builder
for _, cmd := range All() {
helpText.WriteString("/" + cmd.Name() + " - " + cmd.Help() + "\n")
}
msg := tgbotapi.NewMessage(update.Message.Chat.ID, helpText.String())
bot.Send(msg)
}
func init() {
Register(HelpCommand{})
}