nechotron/command.go

25 lines
459 B
Go

package nechotron
import "strings"
type Command struct {
Body string
IsAdminOnly bool
}
func NewCommand(body string, isAdminOnly bool) *Command {
return &Command{
Body: body,
IsAdminOnly: isAdminOnly,
}
}
func (c *Command) String() string {
return "/" + c.Body
}
func (c *Command) Param(text string) string {
return strings.TrimPrefix(text, "/"+c.Body+" ")
}
// func HandleCommand(command *Command, handler cmdFunc) (bool, error)