bot

package
Version: v0.0.0-...-d462298 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Elapsed = "Elapsed"

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin interface {
	IsUserAdmin(mattermostUserID string) bool
}

type Bot

type Bot interface {
	Poster
	Logger
	Admin

	WithConfig(BotConfig) Bot
}

func NewBot

func NewBot(api plugin.API, botUserID string) Bot

NewBot creates a new bot poster.

type BotConfig

type BotConfig struct {
	// AdminUserIDs contains a comma-separated list of user IDs that are allowed
	// to administer plugin functions, even if not Mattermost sysadmins.
	AdminUserIDs string

	// AdminLogLevel is "debug", "info", "warn", or "error".
	AdminLogLevel string

	// AdminLogVerbose: set to include full context with admin log messages.
	AdminLogVerbose bool
}

func (BotConfig) ToStorable

func (c BotConfig) ToStorable(configMap map[string]interface{}) map[string]interface{}

type LogContext

type LogContext map[string]interface{}

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{})
}

type NilLogger

type NilLogger struct{}

func (*NilLogger) Debugf

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

func (*NilLogger) Errorf

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

func (*NilLogger) Infof

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

func (*NilLogger) Timed

func (l *NilLogger) Timed() Logger

func (*NilLogger) Warnf

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

func (*NilLogger) With

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

type NilPoster

type NilPoster struct{}

func (*NilPoster) DM

func (p *NilPoster) DM(userID, format string, args ...interface{}) error

func (*NilPoster) DMWithAttachments

func (p *NilPoster) DMWithAttachments(userID string, attachments ...*model.SlackAttachment) error

func (*NilPoster) Ephemeral

func (p *NilPoster) Ephemeral(userID, channelID, format string, args ...interface{})

type Poster

type Poster interface {
	// 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{})
}

type TestLogger

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

func (*TestLogger) Debugf

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

func (*TestLogger) Errorf

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

func (*TestLogger) Infof

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

func (*TestLogger) Timed

func (l *TestLogger) Timed() Logger

func (*TestLogger) Warnf

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

func (*TestLogger) With

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

type TestPost

type TestPost struct {
	UserID      string
	ChannelID   string
	Message     string
	Attachments []*model.SlackAttachment
}

type TestPoster

type TestPoster struct {
	DirectPosts    []TestPost
	EphemeralPosts []TestPost
}

func (*TestPoster) DM

func (p *TestPoster) DM(userID, format string, args ...interface{}) error

func (*TestPoster) DMWithAttachments

func (p *TestPoster) DMWithAttachments(userID string, attachments ...*model.SlackAttachment) error

func (*TestPoster) Ephemeral

func (p *TestPoster) Ephemeral(userID, channelID, format string, args ...interface{})

func (*TestPoster) Reset

func (p *TestPoster) Reset()

Jump to

Keyboard shortcuts

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