Documentation ¶
Overview ¶
Package chatcommand implements event.Handler for PRIVMSG based IRC commands. It integrates with permissions.Handler
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrCmdExists = errors.New("command exists") ErrCmdNoExist = errors.New("command does not exist") ErrInvalidCmdName = errors.New("invalid command name") ErrNoHelp = errors.New("cannot add a command with no help message") )
AddCommand errors
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct { CommandName string Arguments []string Event *event.Message Target string Reply func(string) }
Argument represents an argument to a command
func (*Argument) CurrentNick ¶
CurrentNick is a shortcut to event.CurrentNick. It will be inlined
func (*Argument) Replyf ¶
Replyf is a thin wrapper around reply that allows for easy printf formatting of replies
func (*Argument) SourceUser ¶
func (a *Argument) SourceUser() *user.EphemeralUser
SourceUser is a shortcut to event.SourceUser. It will be inlined
type CommandPanicedError ¶
type CommandPanicedError struct { CommandName string PanicData interface{} // contains filtered or unexported fields }
CommandPanicedError is returned from OnMessage if a command panics
func (*CommandPanicedError) Error ¶
func (e *CommandPanicedError) Error() string
type Handler ¶
type Handler struct { Prefix string // Function used to send messages. It is expected that this can handle overlong lines cleanly. MessageFunc func(string, string) error // A permission system to use. If nil, no permission checks take place PermissionHandler permissions.Handler // contains filtered or unexported fields }
Handler implements a chat message command system. You must provide a prefix and MessageFunc for replies
func (*Handler) AddCommand ¶
func (h *Handler) AddCommand( name, help string, requiredPermissions []string, requiredArgs int, callback Callback, ) error
AddCommand adds a new command to the Handler
func (*Handler) DoHelp ¶
DoHelp generates the help message for a given command, or a general help message if the command is ""