bot

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 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

This section is empty.

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
	BotName() string
	notifier.Notifier
}

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) SendEvent added in v0.13.0

func (b *Discord) SendEvent(_ context.Context, event event.Event, eventSources []string) (err error)

SendEvent sends event notification to Discord ChannelID. Context is not supported by client: See https://github.com/bwmarrin/discordgo/issues/752.

func (*Discord) SendGenericMessage added in v0.16.0

func (b *Discord) SendGenericMessage(_ context.Context, genericMsg interactive.GenericMessage, sourceBindings []string) error

SendGenericMessage 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.Message) 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 EventCommandProvider added in v0.15.0

type EventCommandProvider interface {
	GetCommandsForEvent(event event.Event, executorBindings []string) ([]kubectl.Command, error)
}

EventCommandProvider describes a provider for event commands.

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) SendEvent added in v0.13.0

func (b *Mattermost) SendEvent(_ context.Context, event event.Event, eventSources []string) error

SendEvent sends event notification to Mattermost

func (*Mattermost) SendGenericMessage added in v0.16.0

func (b *Mattermost) SendGenericMessage(_ context.Context, genericMsg interactive.GenericMessage, sourceBindings []string) error

SendGenericMessage sends message to selected Mattermost channels.

func (*Mattermost) SendMessageToAll added in v0.16.0

func (b *Mattermost) SendMessageToAll(_ context.Context, msg interactive.Message) 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 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) SendEvent added in v0.13.0

func (b *Slack) SendEvent(ctx context.Context, event event.Event, eventSources []string) error

SendEvent sends event notification to slack

func (*Slack) SendGenericMessage added in v0.16.0

func (b *Slack) SendGenericMessage(_ context.Context, genericMsg interactive.GenericMessage, sourceBindings []string) error

SendGenericMessage sends message to selected Slack channels.

func (*Slack) SendMessageToAll added in v0.16.0

func (b *Slack) SendMessageToAll(ctx context.Context, msg interactive.Message) 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(notificationType config.Notification) *SlackRenderer

NewSlackRenderer returns new SlackRenderer instance.

func (*SlackRenderer) RenderAsSlackBlocks added in v0.14.0

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

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

func (*SlackRenderer) RenderEventMessage added in v0.14.0

func (b *SlackRenderer) RenderEventMessage(event event.Event, additionalSections ...interactive.Section) interactive.Message

RenderEventMessage returns Slack interactive message based on a given event.

func (*SlackRenderer) RenderInteractiveMessage added in v0.14.0

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

RenderInteractiveMessage returns Slack message based on the input msg.

func (*SlackRenderer) RenderLegacyEventMessage added in v0.15.0

func (b *SlackRenderer) RenderLegacyEventMessage(event event.Event) slack.Attachment

RenderLegacyEventMessage returns Slack message based on a given event.

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, eventCmdProvider EventCommandProvider, 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) SendEvent added in v0.14.0

func (b *SocketSlack) SendEvent(ctx context.Context, event event.Event, eventSources []string) error

SendEvent sends event notification to slack

func (*SocketSlack) SendGenericMessage added in v0.16.0

func (b *SocketSlack) SendGenericMessage(_ context.Context, genericMsg interactive.GenericMessage, sourceBindings []string) error

SendGenericMessage sends message with interactive sections to selectred Slack channels.

func (*SocketSlack) SendMessageToAll added in v0.16.0

func (b *SocketSlack) SendMessageToAll(ctx context.Context, msg interactive.Message) 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
	Notification config.Notification
	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) SendEvent added in v0.13.0

func (b *Teams) SendEvent(ctx context.Context, event event.Event, eventSources []string) error

SendEvent sends event message via Bot interface

func (*Teams) SendGenericMessage added in v0.16.0

func (b *Teams) SendGenericMessage(ctx context.Context, genericMsg interactive.GenericMessage, sourceBindings []string) error

SendGenericMessage 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.Message) 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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