bot

package
v0.0.0-...-9979fab Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON(ref interface{}) string

JSON .

func JSONBlock

func JSONBlock(ref interface{}) string

JSONBlock .

Types

type Bot

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

Bot stores the information for the plugin configuration, and implements the Poster and Logger interfaces.

func New

func New(api *pluginapi.Client, botUserID string, configService config.Service) *Bot

New creates a new bot poster/logger.

func (*Bot) DM

func (b *Bot) DM(userID, format string, args ...interface{}) error

DM posts a simple Direct Message to the specified user

func (*Bot) DMWithAttachments

func (b *Bot) DMWithAttachments(userID string, attachments ...*model.SlackAttachment) error

DMWithAttachments posts a Direct Message that contains Slack attachments. Often used to include post actions.

func (*Bot) Debugf

func (b *Bot) Debugf(format string, args ...interface{})

Debugf .

func (*Bot) Ephemeral

func (b *Bot) Ephemeral(userID, channelID, format string, args ...interface{})

Ephemeral sends an ephemeral message to a user

func (*Bot) Errorf

func (b *Bot) Errorf(format string, args ...interface{})

Errorf .

func (*Bot) Infof

func (b *Bot) Infof(format string, args ...interface{})

Infof .

func (*Bot) PostMessage

func (b *Bot) PostMessage(channelID, format string, args ...interface{}) (string, error)

PostMessage posts a message to a specified channel.

func (*Bot) PublishWebsocketEventToChannel

func (b *Bot) PublishWebsocketEventToChannel(event string, payload interface{}, channelID string)

PublishWebsocketEventToChannel sends a websocket event with payload to channelID

func (*Bot) PublishWebsocketEventToTeam

func (b *Bot) PublishWebsocketEventToTeam(event string, payload interface{}, teamID string)

PublishWebsocketEventToTeam sends a websocket event with payload to teamID

func (*Bot) PublishWebsocketEventToUser

func (b *Bot) PublishWebsocketEventToUser(event string, payload interface{}, userID string)

PublishWebsocketEventToUser sends a websocket event with payload to userID

func (*Bot) Timed

func (b *Bot) Timed() Logger

Timed .

func (*Bot) Warnf

func (b *Bot) Warnf(format string, args ...interface{})

Warnf .

func (*Bot) With

func (b *Bot) With(logContext LogContext) Logger

With .

type LogContext

type LogContext map[string]interface{}

LogContext .

type Logger

type Logger interface {
	With(LogContext) Logger
	Timed() Logger
	Debugf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
}

Logger interface - a logging system that will tee logs to a DM channel.

type NilLogger

type NilLogger struct{}

NilLogger Nil logger.

func (*NilLogger) Debugf

func (l *NilLogger) Debugf(format string, args ...interface{})

Debugf .

func (*NilLogger) Errorf

func (l *NilLogger) Errorf(format string, args ...interface{})

Errorf .

func (*NilLogger) Infof

func (l *NilLogger) Infof(format string, args ...interface{})

Infof .

func (*NilLogger) Timed

func (l *NilLogger) Timed() Logger

Timed .

func (*NilLogger) Warnf

func (l *NilLogger) Warnf(format string, args ...interface{})

Warnf .

func (*NilLogger) With

func (l *NilLogger) With(logContext LogContext) Logger

With .

type Poster

type Poster interface {
	// PostMessage posts a simple Direct Message to the specified user. Returns the post id if posting was successful
	PostMessage(channelID, format string, args ...interface{}) (createdPostID string, err error)

	// DM posts a simple Direct Message to the specified user.
	DM(userID, format string, args ...interface{}) error

	// DMWithAttachments posts a Direct Message that contains Slack attachments.
	// Often used to include post actions.
	DMWithAttachments(userID string, attachments ...*model.SlackAttachment) error

	// Ephemeral sends an ephemeral message to a user.
	Ephemeral(userID, channelID, format string, args ...interface{})

	// PublishWebsocketEventToTeam sends a websocket event with payload to teamID.
	PublishWebsocketEventToTeam(event string, payload interface{}, teamID string)

	// PublishWebsocketEventToChannel sends a websocket event with payload to channelID.
	PublishWebsocketEventToChannel(event string, payload interface{}, channelID string)

	// PublishWebsocketEventToUser sends a websocket event with payload to userID.
	PublishWebsocketEventToUser(event string, payload interface{}, userID string)
}

Poster interface - a small subset of the plugin posting API.

type TestLogger

type TestLogger struct {
	testing.TB
	// contains filtered or unexported fields
}

TestLogger test logger.

func (*TestLogger) Debugf

func (l *TestLogger) Debugf(format string, args ...interface{})

Debugf .

func (*TestLogger) Errorf

func (l *TestLogger) Errorf(format string, args ...interface{})

Errorf .

func (*TestLogger) Infof

func (l *TestLogger) Infof(format string, args ...interface{})

Infof .

func (*TestLogger) Timed

func (l *TestLogger) Timed() Logger

Timed .

func (*TestLogger) Warnf

func (l *TestLogger) Warnf(format string, args ...interface{})

Warnf .

func (*TestLogger) With

func (l *TestLogger) With(logContext LogContext) Logger

With .

Jump to

Keyboard shortcuts

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