Documentation ¶
Index ¶
- type Handler
- type Helper
- type Mux
- func (mx *Mux) Background(hs ...hugot.BackgroundHandler) error
- func (mx *Mux) CommandSetup(cmd *command.Command) error
- func (mx *Mux) Describe() (string, string)
- func (mx *Mux) HandleHTTP(h hugot.WebHookHandler)
- func (mx *Mux) Hears(hs ...hears.Hearer) error
- func (mx *Mux) ProcessMessage(ctx context.Context, w hugot.ResponseWriter, m *hugot.Message) error
- func (mx *Mux) Raw(hs ...hugot.Handler) error
- func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (mx *Mux) SetAdapter(a hugot.Adapter)
- func (mx *Mux) SetURL(b *url.URL)
- func (mx *Mux) StartBackground(ctx context.Context, w hugot.ResponseWriter)
- func (mx *Mux) URL() *url.URL
- type Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements the help handler.
type Mux ¶
type Mux struct { sync.RWMutex ToBot hugot.Handler // Handles message aimed directly at the bot RawHandlers []hugot.Handler // Raw handlers BGHandlers []hugot.BackgroundHandler // Long running background handlers Webhooks map[string]hugot.WebHookHandler // WebHooks HearsHandlers map[*regexp.Regexp][]hears.Hearer // Hearing handlers // contains filtered or unexported fields }
Mux is a Handler that multiplexes messages to a set of Command, Hears, and Raw handlers.
func (*Mux) Background ¶
func (mx *Mux) Background(hs ...hugot.BackgroundHandler) error
Background adds the provided handler to the Mux. It will be started with the Mux is started.
func (*Mux) HandleHTTP ¶
func (mx *Mux) HandleHTTP(h hugot.WebHookHandler)
HandleHTTP registers h as a WebHook handler. The name of the Mux, and the name of the handler are used to construct a unique URL that can be used to send web requests to this handler
func (*Mux) Hears ¶
Hears adds the provided handler to the mux. all messages matching the hears patterns will be forwarded to the handler.
func (*Mux) ProcessMessage ¶
ProcessMessage implements the Handler interface. Message will first be passed to any registered RawHandlers. If the message has been deemed, by the Adapter to have been sent directly to the bot, any comand handlers will be processed. Then, if appropriate, the message will be matched against any Hears patterns and all matching Heard functions will then be called. Any unrecognized errors from the Command handlers will be passed back to the user that sent us the message.
func (*Mux) Raw ¶
Raw adds the provided handlers to the Mux. All messages sent to the mux will be forwarded to this handler.
func (*Mux) ServeHTTP ¶
func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP iplements http.ServeHTTP for a Mux to allow it to act as a web server.
func (*Mux) SetAdapter ¶
SetAdapter sets the adapter on all the webhook of this mux.
func (*Mux) StartBackground ¶
func (mx *Mux) StartBackground(ctx context.Context, w hugot.ResponseWriter)
StartBackground starts any registered background handlers.