triggers

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

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 (cmd *Command) AddParameter(name string, regex string) *Command

func (*Command) AddParameterWithDefault added in v0.1.0

func (cmd *Command) AddParameterWithDefault(name string, regex string, defaultValue string) *Command

func (*Command) AddParameterWithDefaultCb added in v0.1.0

func (cmd *Command) AddParameterWithDefaultCb(name string, regex string, defaultCb argsCallback) *Command

func (*Command) AllowChannel

func (cmd *Command) AllowChannel() *Command

Allows triggering the command via public message in a channel

func (*Command) AllowPrivate

func (cmd *Command) AllowPrivate() *Command

Helper functions when initializing from ircbot.IrcBot.AddCommand Allows triggering the command via private message to the bot

func (*Command) Arguments

func (cmd *Command) Arguments(argRegexp string) *Command

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) Handle

func (cmd Command) Handle(irc *hbot.Bot, m *hbot.Message) bool

func (Command) Help

func (cmd Command) Help() string

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

func (*Command) SetHelp

func (cmd *Command) SetHelp(msg string) *Command

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.

func (EvHandler) Handle

func (ev EvHandler) Handle(irc *hbot.Bot, m *hbot.Message) bool

Handle manages event hooks to see if they're appliable to the incoming request

func (EvHandler) Help

func (ev EvHandler) Help() string

type HelpHandler

type HelpHandler interface {
	Handle(*hbot.Bot, *hbot.Message) bool
	Help() string
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a container for all event handlers.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new empty registry.

func (*Registry) AddAll

func (r *Registry) AddAll(b *bot.Bot, c *bot.Configuration)

func (*Registry) Deregister

func (r *Registry) Deregister(id string)

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

func (r *Registry) RegisterCommand(command *Command) error

RegisterCommand allows to register a full-featured IRC command.

func (*Registry) RegisterCommands

func (r *Registry) RegisterCommands(commands []*Command) error

type TriggerFunc

type TriggerFunc func(*hbot.Bot, *hbot.Message, *sql.DB, *bot.Configuration) bool

TriggerFunc is the format of the functions we expect. They depend on the irc bot, the message, the db and the configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL