Dispatcher, Commands, Filters, Markdown escaping

This commit is contained in:
2023-01-22 23:54:54 +03:00
parent 677f28182a
commit e2ba9565d5
8 changed files with 133 additions and 20 deletions

24
command.go Normal file
View 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)