Documentation ¶
Index ¶
- type Command
- func (cmd *Command) AddParameter(name string, regex string) *Command
- func (cmd *Command) AddParameterWithDefault(name string, regex string, defaultValue string) *Command
- func (cmd *Command) AddParameterWithDefaultCb(name string, regex string, defaultCb argsCallback) *Command
- func (cmd *Command) AllowChannel() *Command
- func (cmd *Command) AllowPrivate() *Command
- func (cmd *Command) Arguments(argRegexp string) *Command
- func (cmd Command) Handle(irc *hbot.Bot, m *hbot.Message) bool
- func (cmd Command) Help() string
- func (cmd *Command) InitParams()
- func (cmd *Command) Parameter(name string) *CommandArgument
- func (cmd *Command) SetHelp(msg string) *Command
- type CommandArgument
- type CommandClosure
- type EvHandler
- type HelpHandler
- type Registry
- func (r *Registry) AddAll(b *bot.Bot, c *bot.Configuration)
- func (r *Registry) Deregister(id string)
- func (r *Registry) Register(id string, handler TriggerFunc, help string, db *sql.DB, c *bot.Configuration) error
- func (r *Registry) RegisterCommand(command *Command) error
- func (r *Registry) RegisterCommands(commands []*Command) error
- type TriggerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { // The command identifier - it will determine how // the command is called ID string ArgumentsRegexp *regexp.Regexp HelpMsg string Action CommandClosure Db *sql.DB Configuration *bot.Configuration // contains filtered or unexported fields }
Command encapsulates an irc command
func (*Command) AddParameter ¶ added in v0.1.0
func (*Command) AddParameterWithDefault ¶ added in v0.1.0
func (*Command) AddParameterWithDefaultCb ¶ added in v0.1.0
func (*Command) AllowChannel ¶
Allows triggering the command via public message in a channel
func (*Command) AllowPrivate ¶
Helper functions when initializing from ircbot.IrcBot.AddCommand Allows triggering the command via private message to the bot
func (*Command) Arguments ¶
Add all arguments in a single regexp the regexp must use named grouped parameters. Deprecated: you should use the AddParameter* functions instead, which provide more advanced handling.
func (*Command) InitParams ¶ added in v0.1.0
func (cmd *Command) InitParams()
func (*Command) Parameter ¶ added in v0.1.0
func (cmd *Command) Parameter(name string) *CommandArgument
type CommandArgument ¶ added in v0.1.0
type CommandArgument struct {
// contains filtered or unexported fields
}
func (*CommandArgument) Default ¶ added in v0.1.0
func (c *CommandArgument) Default(value string)
Set default value
func (*CommandArgument) Get ¶ added in v0.1.0
func (c *CommandArgument) Get(value string, m *hbot.Message) string
func (*CommandArgument) SetValidator ¶ added in v0.1.0
func (c *CommandArgument) SetValidator(reg string)
func (*CommandArgument) Validate ¶ added in v0.1.1
func (c *CommandArgument) Validate(value string) error
type CommandClosure ¶
type CommandClosure func( map[string]string, *hbot.Bot, *hbot.Message, *bot.Configuration, *sql.DB, ) bool
Commands section
type EvHandler ¶
type EvHandler struct { Handler TriggerFunc HelpMsg string Config *bot.Configuration Db *sql.DB }
EvHandler is the basic structure for holding information about an irc trigger. For most interactive commands, where you want to define ACLs, input validation, etc. you should use Command instead.
type HelpHandler ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a container for all event handlers.
func (*Registry) Deregister ¶
Deregister removes one handler from the system.
func (*Registry) Register ¶
func (r *Registry) Register(id string, handler TriggerFunc, help string, db *sql.DB, c *bot.Configuration) error
Register an handler. This is the basic interface you should use if you're not crating a proper command, but rather a trigger. For interactive commands, please use RegisterCommand below.
func (*Registry) RegisterCommand ¶
RegisterCommand allows to register a full-featured IRC command.