bot

package
v0.0.0-...-382b95a Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

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

Bot structure

func New

func New(sc *slack.Client, tc *trace.Client, devMode bool, log Logger, h Handler, jh JoinHandler) *Bot

New will create a new Bot.

func (*Bot) Init

func (b *Bot) Init(ctx context.Context) error

Init must be called before anything else in order to initialize the bot

func (*Bot) PostMessage

func (b *Bot) PostMessage(ctx context.Context, channel, text string, opts ...slack.MsgOption) error

PostMessage sends messages to a Slack channel.

Links and media is not unfurled.

type Handler

type Handler interface {
	Handle(context.Context, Message, Responder)
}

A Handler responds to a message.

type HandlerFunc

type HandlerFunc func(context.Context, Message, Responder)

HandlerFunc adapts a function to be a Handler.

func (HandlerFunc) Handle

func (f HandlerFunc) Handle(ctx context.Context, m Message, r Responder)

Handle calls f(ctx, m, r).

type JoinHandler

type JoinHandler interface {
	Handle(ctx context.Context, event *slack.TeamJoinEvent, r JoinResponder)
}

A JoinHandler responds to a user joining the Slack team.

type JoinHandlerFunc

type JoinHandlerFunc func(ctx context.Context, event *slack.TeamJoinEvent, r JoinResponder)

JoinHandlerFunc adapts a function to be a JoinHandler.

func (JoinHandlerFunc) Handle

func (jh JoinHandlerFunc) Handle(ctx context.Context, event *slack.TeamJoinEvent, r JoinResponder)

Handle calls jh(ctx, event, r).

type JoinResponder

type JoinResponder interface {
	RespondPrivate(ctx context.Context, msg string)
}

JoinResponder provides methods for responding to a user joing the Slack team.

type Logger

type Logger func(message string, args ...interface{})

Logger function

type Message

type Message struct {
	Event         *slack.MessageEvent // OriginalEvent
	TrimmedText   string              // Event.Text with whitespace and bot mention removed.
	DirectedToBot bool                // True if @mention to bot or DM to bot.
}

Message contains the slack.MessageEvent and processed information.

type Responder

type Responder interface {
	Respond(ctx context.Context, msg string)
	RespondUnfurled(ctx context.Context, msg string)
	RespondWithAttachment(ctx context.Context, msg, attachment string)
	RespondPrivate(ctx context.Context, msg string)
	RespondPrivateWithAttachment(ctx context.Context, msg, attachment string)
	React(ctx context.Context, reaction string)
}

Responder provides methods for responding to messages.

Jump to

Keyboard shortcuts

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