bot

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: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Background

func Background(hs ...hugot.BackgroundHandler) error

Background adds the provided handler to the Mux of the DefaultBot.

func Command

func Command(c *command.Handler)

Command adds a CLI command to the DefaultBot

func HandleHTTP

func HandleHTTP(h hugot.WebHookHandler)

HandleHTTP adds the provided handler to the Mux of the DefaultBot.

func Hears

func Hears(hs ...hears.Hearer) error

Hears adds the provided handle to the Mux of the DefaultBotr.

func ListenAndServe

func ListenAndServe(ctx context.Context, h hugot.Handler, a hugot.Adapter, as ...hugot.Adapter)

ListenAndServe runs the DefaultBot handler loop.

func Raw

func Raw(hs ...hugot.Handler) error

Raw adds the provided handler to the Mux of the DefaultBot.

func SetURL

func SetURL(b *url.URL)

SetURL sets the base URL for web hooks on the DefaultBot.

func URL

func URL() *url.URL

URL returns the base URL for the Mux of the DefaultBot

Types

type Bot

type Bot struct {
	Store    storage.Storer
	Mux      *mux.Mux
	Commands command.Set
}

Bot is the main type for implementing chat bots. They listen on one or more adapters and pass messages to, and from handlers.

var DefaultBot *Bot

DefaultBot is a default instance of a bot

func New

func New() *Bot

New creates a new bot.

func (*Bot) Command

func (b *Bot) Command(c *command.Handler)

Command adds a CLI command to the Bot

func (*Bot) ListenAndServe

func (b *Bot) ListenAndServe(ctx context.Context, h hugot.Handler, a hugot.Adapter, as ...hugot.Adapter)

ListenAndServe runs the handler h, passing all messages to/from the provided adapter. The context may be used to gracefully shut down the server.

Jump to

Keyboard shortcuts

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