bot

package
v1.0.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WebSocketProtocol stores protocol initials for web socket
	WebSocketProtocol = "ws://"
	// WebSocketSecureProtocol stores protocol initials for web socket
	WebSocketSecureProtocol = "wss://"
)

Variables

This section is empty.

Functions

func AsNotifiers added in v1.0.0

func AsNotifiers(bots map[string]Bot) []notifier.Bot

func IsValidNonInteractiveSingleSection added in v1.0.0

func IsValidNonInteractiveSingleSection(msg interactive.CoreMessage) error

Types

type AnalyticsReporter added in v0.13.0

type AnalyticsReporter interface {
	// ReportBotEnabled reports an enabled bot.
	ReportBotEnabled(platform config.CommPlatformIntegration) error
}

AnalyticsReporter defines a reporter that collects analytics data.

type Bot

type Bot interface {
	Start(ctx context.Context) error
	notifier.Bot
}

Bot connects to communication channels and reads/sends messages. It is a two-way integration.

type Discord added in v0.13.0

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

Discord listens for user's message, execute commands and sends back the response.

func NewDiscord added in v0.13.0

func NewDiscord(log logrus.FieldLogger, commGroupName string, cfg config.Discord, executorFactory ExecutorFactory, reporter AnalyticsReporter) (*Discord, error)

NewDiscord creates a new Discord instance.

func (*Discord) BotName added in v0.14.0

func (b *Discord) BotName() string

BotName returns the Bot name.

func (*Discord) IntegrationName added in v0.13.0

func (b *Discord) IntegrationName() config.CommPlatformIntegration

IntegrationName describes the integration name.

func (*Discord) NotificationsEnabled added in v0.13.0

func (b *Discord) NotificationsEnabled(channelID string) bool

NotificationsEnabled returns current notification status for a given channel ID.

func (*Discord) SendMessage added in v0.13.0

func (b *Discord) SendMessage(_ context.Context, msg interactive.CoreMessage, sourceBindings []string) error

SendMessage sends interactive message to selected Discord channels. Context is not supported by client: See https://github.com/bwmarrin/discordgo/issues/752.

func (*Discord) SendMessageToAll added in v0.16.0

func (b *Discord) SendMessageToAll(_ context.Context, msg interactive.CoreMessage) error

SendMessageToAll sends interactive message to all Discord channels. Context is not supported by client: See https://github.com/bwmarrin/discordgo/issues/752.

func (*Discord) SetNotificationsEnabled added in v0.13.0

func (b *Discord) SetNotificationsEnabled(channelID string, enabled bool) error

SetNotificationsEnabled sets a new notification status for a given channel ID.

func (*Discord) Start added in v0.13.0

func (b *Discord) Start(ctx context.Context) error

Start starts the Discord websocket connection and listens for messages.

func (*Discord) Type added in v0.13.0

func (b *Discord) Type() config.IntegrationType

Type describes the integration type.

type DiscordRenderer added in v1.0.0

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

DiscordRenderer provides functionality to render Discord specific messages from a generic models.

func NewDiscordRenderer added in v1.0.0

func NewDiscordRenderer() *DiscordRenderer

NewDiscordRenderer returns new DiscordRenderer instance.

func (*DiscordRenderer) MessageToMarkdown added in v1.0.0

func (d *DiscordRenderer) MessageToMarkdown(in interactive.CoreMessage) string

MessageToMarkdown renders message in Markdown format.

func (*DiscordRenderer) NonInteractiveSectionToCard added in v1.0.0

func (d *DiscordRenderer) NonInteractiveSectionToCard(msg interactive.CoreMessage) (discordgo.MessageEmbed, error)

NonInteractiveSectionToCard returns MessageEmbed for the given event message. Note: It cannot be used for other messages as we take into account only first message section with limited primitives: - TextFields - BulletLists - Timestamp It should be removed once we will add support for a proper message renderer.

type ExecutorFactory added in v0.13.0

type ExecutorFactory interface {
	NewDefault(cfg execute.NewDefaultInput) execute.Executor
}

ExecutorFactory facilitates creation of execute.Executor instances.

type FatalErrorAnalyticsReporter added in v0.13.0

type FatalErrorAnalyticsReporter interface {
	AnalyticsReporter

	// ReportFatalError reports a fatal app error.
	ReportFatalError(err error) error

	// Close cleans up the reporter resources.
	Close() error
}

FatalErrorAnalyticsReporter reports a fatal errors.

type Mattermost added in v0.13.0

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

Mattermost listens for user's message, execute commands and sends back the response.

func NewMattermost added in v0.13.0

func NewMattermost(log logrus.FieldLogger, commGroupName string, cfg config.Mattermost, executorFactory ExecutorFactory, reporter AnalyticsReporter) (*Mattermost, error)

NewMattermost creates a new Mattermost instance.

func (*Mattermost) BotName added in v0.14.0

func (b *Mattermost) BotName() string

BotName returns the Bot name.

func (*Mattermost) IntegrationName added in v0.13.0

func (b *Mattermost) IntegrationName() config.CommPlatformIntegration

IntegrationName describes the notifier integration name.

func (*Mattermost) NotificationsEnabled added in v0.13.0

func (b *Mattermost) NotificationsEnabled(channelID string) bool

NotificationsEnabled returns current notification status for a given channel ID.

func (*Mattermost) SendMessage added in v0.13.0

func (b *Mattermost) SendMessage(_ context.Context, msg interactive.CoreMessage, sourceBindings []string) error

SendMessage sends message to selected Mattermost channels.

func (*Mattermost) SendMessageToAll added in v0.16.0

func (b *Mattermost) SendMessageToAll(_ context.Context, msg interactive.CoreMessage) error

SendMessageToAll sends message to all Mattermost channels.

func (*Mattermost) SetNotificationsEnabled added in v0.13.0

func (b *Mattermost) SetNotificationsEnabled(channelID string, enabled bool) error

SetNotificationsEnabled sets a new notification status for a given channel ID.

func (*Mattermost) Start added in v0.13.0

func (b *Mattermost) Start(ctx context.Context) error

Start establishes mattermost connection and listens for messages

func (*Mattermost) Type added in v0.13.0

func (b *Mattermost) Type() config.IntegrationType

Type describes the notifier type.

type MattermostRenderer added in v1.0.0

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

MattermostRenderer provides functionality to render Mattermost specific messages from a generic models.

func NewMattermostRenderer added in v1.0.0

func NewMattermostRenderer() *MattermostRenderer

NewMattermostRenderer returns new MattermostRenderer instance.

func (*MattermostRenderer) MessageToMarkdown added in v1.0.0

func (d *MattermostRenderer) MessageToMarkdown(in interactive.CoreMessage) string

MessageToMarkdown renders message in Markdown format.

func (*MattermostRenderer) NonInteractiveSectionToCard added in v1.0.0

func (d *MattermostRenderer) NonInteractiveSectionToCard(msg interactive.CoreMessage) ([]*model.SlackAttachment, error)

NonInteractiveSectionToCard returns MessageEmbed for the given event message. Note: It cannot be used for other messages as we take into account only first message section with limited primitives: - TextFields - BulletLists - Timestamp It should be removed once we will add support for a proper message renderer.

type Slack added in v0.13.0

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

Slack listens for user's message, execute commands and sends back the response.

func NewSlack added in v0.13.0

func NewSlack(log logrus.FieldLogger, commGroupName string, cfg config.Slack, executorFactory ExecutorFactory, reporter FatalErrorAnalyticsReporter) (*Slack, error)

NewSlack creates a new Slack instance.

func (*Slack) BotName added in v0.14.0

func (b *Slack) BotName() string

BotName returns the Bot name.

func (*Slack) IntegrationName added in v0.13.0

func (b *Slack) IntegrationName() config.CommPlatformIntegration

IntegrationName describes the notifier integration name.

func (*Slack) NotificationsEnabled added in v0.13.0

func (b *Slack) NotificationsEnabled(channelName string) bool

NotificationsEnabled returns current notification status for a given channel name.

func (*Slack) SendMessage added in v0.13.0

func (b *Slack) SendMessage(ctx context.Context, msg interactive.CoreMessage, sourceBindings []string) error

SendMessage sends message to selected Slack channels.

func (*Slack) SendMessageToAll added in v0.16.0

func (b *Slack) SendMessageToAll(ctx context.Context, msg interactive.CoreMessage) error

SendMessageToAll sends message to all Slack channels.

func (*Slack) SetNotificationsEnabled added in v0.13.0

func (b *Slack) SetNotificationsEnabled(channelName string, enabled bool) error

SetNotificationsEnabled sets a new notification status for a given channel name.

func (*Slack) Start added in v0.13.0

func (b *Slack) Start(ctx context.Context) error

Start starts the Slack RTM connection and listens for messages

func (*Slack) Type added in v0.13.0

func (b *Slack) Type() config.IntegrationType

Type describes the notifier type.

type SlackRenderer added in v0.14.0

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

SlackRenderer provides functionality to render Slack specific messages from a generic models.

func NewSlackRenderer added in v0.14.0

func NewSlackRenderer() *SlackRenderer

NewSlackRenderer returns new SlackRenderer instance.

func (*SlackRenderer) MessageToMarkdown added in v1.0.0

func (b *SlackRenderer) MessageToMarkdown(in interactive.CoreMessage) string

MessageToMarkdown renders message in Markdown format.

func (*SlackRenderer) RenderAsSlackBlocks added in v0.14.0

func (b *SlackRenderer) RenderAsSlackBlocks(msg interactive.CoreMessage) []slack.Block

RenderAsSlackBlocks returns the Slack message blocks for a given input message.

func (*SlackRenderer) RenderInteractiveMessage added in v0.14.0

func (b *SlackRenderer) RenderInteractiveMessage(msg interactive.CoreMessage) slack.MsgOption

RenderInteractiveMessage returns Slack message based on the input msg.

func (*SlackRenderer) RenderModal added in v0.14.0

RenderModal returns a modal request view based on a given message.

type SocketSlack added in v0.14.0

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

SocketSlack listens for user's message, execute commands and sends back the response.

func NewSocketSlack added in v0.14.0

func NewSocketSlack(log logrus.FieldLogger, commGroupName string, cfg config.SocketSlack, executorFactory ExecutorFactory, reporter socketSlackAnalyticsReporter) (*SocketSlack, error)

NewSocketSlack creates a new SocketSlack instance.

func (*SocketSlack) BotName added in v0.14.0

func (b *SocketSlack) BotName() string

BotName returns the Bot name.

func (*SocketSlack) IntegrationName added in v0.14.0

func (b *SocketSlack) IntegrationName() config.CommPlatformIntegration

IntegrationName describes the notifier integration name.

func (*SocketSlack) NotificationsEnabled added in v0.14.0

func (b *SocketSlack) NotificationsEnabled(channelName string) bool

NotificationsEnabled returns current notification status for a given channel name.

func (*SocketSlack) SendMessage added in v0.14.0

func (b *SocketSlack) SendMessage(ctx context.Context, msg interactive.CoreMessage, sourceBindings []string) error

SendMessage sends message with interactive sections to selected Slack channels.

func (*SocketSlack) SendMessageToAll added in v0.16.0

func (b *SocketSlack) SendMessageToAll(ctx context.Context, msg interactive.CoreMessage) error

SendMessageToAll sends message with interactive sections to all Slack channels.

func (*SocketSlack) SetNotificationsEnabled added in v0.14.0

func (b *SocketSlack) SetNotificationsEnabled(channelName string, enabled bool) error

SetNotificationsEnabled sets a new notification status for a given channel name.

func (*SocketSlack) Start added in v0.14.0

func (b *SocketSlack) Start(ctx context.Context) error

Start starts the Slack WebSocket connection and listens for messages

func (*SocketSlack) Type added in v0.14.0

Type describes the notifier type.

type Teams added in v0.13.0

type Teams struct {
	AppID       string
	AppPassword string
	MessagePath string
	Port        string
	ClusterName string
	Adapter     core.Adapter
	// contains filtered or unexported fields
}

Teams listens for user's message, execute commands and sends back the response.

func NewTeams added in v0.13.0

func NewTeams(log logrus.FieldLogger, commGroupName string, cfg config.Teams, clusterName string, executorFactory ExecutorFactory, reporter AnalyticsReporter) (*Teams, error)

NewTeams creates a new Teams instance.

func (*Teams) BotName added in v0.13.0

func (b *Teams) BotName() string

BotName returns the Bot name.

func (*Teams) IntegrationName added in v0.13.0

func (b *Teams) IntegrationName() config.CommPlatformIntegration

IntegrationName describes the integration name.

func (*Teams) NotificationsEnabled added in v0.13.0

func (b *Teams) NotificationsEnabled(channelID string) bool

NotificationsEnabled returns current notification status for a given channel ID.

func (*Teams) SendMessage added in v0.13.0

func (b *Teams) SendMessage(ctx context.Context, msg interactive.CoreMessage, sourceBindings []string) error

SendMessage sends message to MS Teams to selected conversations.

func (*Teams) SendMessageToAll added in v0.16.0

func (b *Teams) SendMessageToAll(ctx context.Context, msg interactive.CoreMessage) error

SendMessageToAll sends message to MS Teams to all conversations.

func (*Teams) SetNotificationsEnabled added in v0.13.0

func (b *Teams) SetNotificationsEnabled(enabled bool, ref schema.ConversationReference) error

SetNotificationsEnabled sets a new notification status for a given channel ID.

func (*Teams) Start added in v0.13.0

func (b *Teams) Start(ctx context.Context) error

Start MS Teams server to serve messages from Teams client

func (*Teams) Type added in v0.13.0

func (b *Teams) Type() config.IntegrationType

Type describes the integration type.

type TeamsRenderer added in v1.0.0

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

TeamsRenderer provides functionality to render MS Teams specific messages from a generic models.

func NewTeamsRenderer added in v1.0.0

func NewTeamsRenderer() *TeamsRenderer

NewTeamsRenderer return a new TeamsRenderer instance.

func (*TeamsRenderer) MessageToMarkdown added in v1.0.0

func (r *TeamsRenderer) MessageToMarkdown(in interactive.CoreMessage) string

MessageToMarkdown renders message in Markdown format.

func (*TeamsRenderer) NonInteractiveSectionToCard added in v1.0.0

func (r *TeamsRenderer) NonInteractiveSectionToCard(msg interactive.CoreMessage) (*cards.Card, error)

NonInteractiveSectionToCard returns AdaptiveCard for the given message. Note: It cannot be used for other messages as we take into account only first message section with limited primitives: - TextFields - BulletLists - Timestamp It should be removed once we will add support for a proper message renderer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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