hears

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	hugot.Handler
	// contains filtered or unexported fields
}

Handler iimplements both the Hearer, and hugot.Handler interfaces

func (*Handler) Describe

func (h *Handler) Describe() (string, string)

Describe returns the description of this handler

func (*Handler) Heard

func (h *Handler) Heard(ctx context.Context, w hugot.ResponseWriter, m *hugot.Message, matches [][]string) error

Heard is called when the handler hears a message matching the regex

func (*Handler) Hears

func (h *Handler) Hears() *regexp.Regexp

Hears returns the regylar expressions this handler wants to match.

type HeardFunc

type HeardFunc func(ctx context.Context, w hugot.ResponseWriter, m *hugot.Message, submatches [][]string) error

HeardFunc describes a function that can be used to hear regex matches.

type Hearer

type Hearer interface {
	hugot.Describer
	Heard(ctx context.Context, w hugot.ResponseWriter, m *hugot.Message, submatches [][]string) error // Called once a message matches, and is passed any submatches from the regexp capture groups
	Hears() *regexp.Regexp                                                                            // Returns the regexp we want to hear
}

Hearer descibres a handler that can be used to match regular expressions.

func New

func New(name, desc string, rgxp *regexp.Regexp, f HeardFunc) Hearer

New wraps f as a Hears handler that reponnds to the regexp provided, with the given name a description

Directories

Path Synopsis
Package tableflip provides an exacmple Hears handler that will flip tables on behalf of embittered users.
Package tableflip provides an exacmple Hears handler that will flip tables on behalf of embittered users.

Jump to

Keyboard shortcuts

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