Documentation ¶
Overview ¶
This package holds bot command parsing and execution code.
Index ¶
- Variables
- func Parse(prefix string, c *proto.Client, m *proto.Message) bool
- func Register(name string, cf CommandFunc)
- type Command
- type CommandFunc
- type ExecuteFunc
- type Param
- func (p *Param) Bool(defaultVal bool) bool
- func (p *Param) F32(defaultVal float32) float32
- func (p *Param) F64(defaultVal float64) float64
- func (p *Param) I16(defaultVal int16) int16
- func (p *Param) I32(defaultVal int32) int32
- func (p *Param) I64(defaultVal int64) int64
- func (p *Param) I8(defaultVal int8) int8
- func (p *Param) U16(defaultVal uint16) uint16
- func (p *Param) U32(defaultVal uint32) uint32
- func (p *Param) U64(defaultVal uint64) uint64
- func (p *Param) U8(defaultVal uint8) uint8
- func (p *Param) Valid() bool
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RegAny = regexp.MustCompile(`^.+$`) RegAlpha = regexp.MustCompile(`^\w+$`) RegHex = regexp.MustCompile(`^0x[a-fA-F0-9]+$`) RegDecimal = regexp.MustCompile(`^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$`) RegOctal = regexp.MustCompile(`^0[0-7]+$`) RegBinary = regexp.MustCompile(`^0b[01]+$`) )
Functions ¶
func Parse ¶
Parse reads incoming message data and tries to parse it into a command structure and then execute it.
func Register ¶
func Register(name string, cf CommandFunc)
Register registers the given command name and constructor. Modules should call this during initialization to register their commands with the bot.
Types ¶
type Command ¶
type Command struct { Name string // Command name. Description string // Command description. Params []Param // Command parameters. Execute ExecuteFunc // Execution handler for the command. Restricted bool // Command is restricted to admin users. }
Command represents a single bot command.
func (*Command) RequiredParamCount ¶
RequiredParamCount counts the number of required parameters.
type ExecuteFunc ¶
ExecuteFunc represents a command execution handler. These are executed in a separate goroutine.
Click to show internal directories.
Click to hide internal directories.