package nechotron import ( "fmt" "strings" ) type Command struct { Body string IsAdminOnly bool Description string } func NewCommand(body string, desc string, isAdminOnly bool) *Command { return &Command{ Body: body, IsAdminOnly: isAdminOnly, Description: desc, } } func (c *Command) String() string { return "/" + c.Body } func (c *Command) Param(text string) string { return strings.TrimPrefix(text, "/"+c.Body+" ") } func MakeCommandList(commands []*Command, format string) string { result := "" for _, command := range commands { result += fmt.Sprintf(format, command.String(), command.Description) } return result } // func HandleCommand(command *Command, handler cmdFunc) (bool, error)