Dispatcher, Commands, Filters, Markdown escaping
This commit is contained in:
24
command.go
Normal file
24
command.go
Normal file
@ -0,0 +1,24 @@
|
||||
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)
|
Reference in New Issue
Block a user