bot

package
v0.0.0-...-33ec1c0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 48 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

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

func IsValidNonInteractiveSingleSection

func IsValidNonInteractiveSingleSection(msg interactive.CoreMessage) error

Types

type AnalyticsCommandReporter

type AnalyticsCommandReporter interface {
	FatalErrorAnalyticsReporter
	ReportCommand(in analytics.ReportCommandInput) error
}

AnalyticsCommandReporter defines a reporter that collects analytics data.

type AnalyticsReporter

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

AnalyticsReporter defines a reporter that collects analytics data.

type Bot

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

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

type CloudSlack

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

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

func NewCloudSlack

func NewCloudSlack(log logrus.FieldLogger,
	commGroupMetadata CommGroupMetadata,
	cfg config.CloudSlack,
	clusterName string,
	executorFactory ExecutorFactory,
	reporter AnalyticsCommandReporter) (*CloudSlack, error)

func (*CloudSlack) BotName

func (b *CloudSlack) BotName() string

func (*CloudSlack) GetStatus

func (b *CloudSlack) GetStatus() health.PlatformStatus

GetStatus gets bot status.

func (*CloudSlack) IntegrationName

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

func (*CloudSlack) NotificationsEnabled

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

NotificationsEnabled returns current notification status for a given channel name.

func (*CloudSlack) SendMessage

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

func (*CloudSlack) SendMessageToAll

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

func (*CloudSlack) SetNotificationsEnabled

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

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

func (*CloudSlack) Start

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

func (*CloudSlack) Type

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

type CloudTeams

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

CloudTeams listens for user's messages, execute commands and sends back the response. It sends also source notifications.

User message (executors) flow:

+-------------+       +-------------+      +-------------+
|   MS Teams' | REST  |   Cloud     | REST |  Pub/Sub    |
|   message   +------>|   router    +----->|  #bot       |
+-------------+       +-------------+      +-------+-----+
                                                   v
+-------------+       +-------------+      +-------------+
|  Pub/Sub    | gRPC  |  Agent      | gRPC |  Cloud      |
|  #agent     |<------+  CloudTeams |<-----+  processor  |
+------+------+       +-------------+      +-------------+
       |
+------v------+       +-------------+
|  Cloud      | REST  |   MS Teams' |
|  processor  |+----->|   channel   |
+-------------+       +-------------+

Notification (sources) flow:

+-------------+       +-------------+      +-------------+
|   Source    | gRPC  |  Agent      | gRPC |  Cloud      |
|   message   +------>|  CloudTeams +----->|  router     |
+-------------+       +-------------+      +-------+-----+
                                                   v
+-------------+       +-------------+      +-------------+
|  MS Teams'  | REST  |  Cloud      | REST |  Pub/Sub    |
|  channel    |<------+  processor  |<-----+  #agent     |
+------+------+       +-------------+      +-------------+

func NewCloudTeams

func NewCloudTeams(
	log logrus.FieldLogger,
	commGroupMetadata CommGroupMetadata,
	cfg config.CloudTeams,
	clusterName string,
	executorFactory ExecutorFactory,
	reporter AnalyticsCommandReporter) (*CloudTeams, error)

NewCloudTeams returns a new CloudTeams instance.

func (*CloudTeams) BotName

func (b *CloudTeams) BotName() string

BotName returns the Bot name.

func (*CloudTeams) GetStatus

func (b *CloudTeams) GetStatus() health.PlatformStatus

GetStatus gets bot status.

func (*CloudTeams) IntegrationName

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

IntegrationName describes the integration name.

func (*CloudTeams) NotificationsEnabled

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

NotificationsEnabled returns current notification status for a given channel ID.

func (*CloudTeams) SendMessage

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

SendMessage sends the message to MS CloudTeams to selected conversations.

func (*CloudTeams) SendMessageToAll

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

SendMessageToAll sends the message to MS CloudTeams to all conversations even if notifications are disabled.

func (*CloudTeams) SetNotificationsEnabled

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

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

func (*CloudTeams) Start

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

Start MS Teams server to serve messages from Teams client

func (*CloudTeams) Type

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

Type describes the integration type.

type CommGroupMetadata

type CommGroupMetadata struct {
	Name  string
	Index int
}

type Discord

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

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

func NewDiscord

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

NewDiscord creates a new Discord instance.

func (*Discord) BotName

func (b *Discord) BotName() string

BotName returns the Bot name.

func (*Discord) GetStatus

func (b *Discord) GetStatus() health.PlatformStatus

GetStatus gets bot status.

func (*Discord) IntegrationName

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

IntegrationName describes the integration name.

func (*Discord) NotificationsEnabled

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

NotificationsEnabled returns current notification status for a given channel ID.

func (*Discord) SendMessage

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

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

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

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

func (*Discord) Start

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

func (*Discord) Type

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

Type describes the integration type.

type DiscordRenderer

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

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

func NewDiscordRenderer

func NewDiscordRenderer() *DiscordRenderer

NewDiscordRenderer returns new DiscordRenderer instance.

func (*DiscordRenderer) MessageToMarkdown

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

MessageToMarkdown renders message in Markdown format.

func (*DiscordRenderer) NonInteractiveSectionToCard

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

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

ExecutorFactory facilitates creation of execute.Executor instances.

type FatalErrorAnalyticsReporter

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

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

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

func NewMattermost

func NewMattermost(ctx context.Context, log logrus.FieldLogger, commGroupMetadata CommGroupMetadata, cfg config.Mattermost, executorFactory ExecutorFactory, reporter AnalyticsReporter) (*Mattermost, error)

NewMattermost creates a new Mattermost instance.

func (*Mattermost) BotName

func (b *Mattermost) BotName() string

BotName returns the Bot name.

func (*Mattermost) GetStatus

func (b *Mattermost) GetStatus() health.PlatformStatus

GetStatus gets bot status.

func (*Mattermost) IntegrationName

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

IntegrationName describes the notifier integration name.

func (*Mattermost) NotificationsEnabled

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

NotificationsEnabled returns current notification status for a given channel ID.

func (*Mattermost) SendMessage

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

SendMessage sends message to selected Mattermost channels.

func (*Mattermost) SendMessageToAll

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

SendMessageToAll sends message to all Mattermost channels.

func (*Mattermost) SetNotificationsEnabled

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

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

func (*Mattermost) Start

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

func (*Mattermost) Type

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

Type describes the notifier type.

type MattermostRenderer

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

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

func NewMattermostRenderer

func NewMattermostRenderer() *MattermostRenderer

NewMattermostRenderer returns new MattermostRenderer instance.

func (*MattermostRenderer) MessageToMarkdown

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

MessageToMarkdown renders message in Markdown format.

func (*MattermostRenderer) NonInteractiveSectionToCard

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 SlackMessageStatusTracker

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

SlackMessageStatusTracker marks messages with emoji for easy tracking the status of Slack messages.

func NewSlackMessageStatusTracker

func NewSlackMessageStatusTracker(log logrus.FieldLogger, client SlackReactionClient) *SlackMessageStatusTracker

NewSlackMessageStatusTracker creates a new instance of SlackMessageStatusTracker.

func (*SlackMessageStatusTracker) GetMsgRef

func (b *SlackMessageStatusTracker) GetMsgRef(event slackMessage) *slack.ItemRef

GetMsgRef retrieves the Slack item reference for a given event. It returns nil if the message doesn't support reactions or lacks necessary information.

func (*SlackMessageStatusTracker) MarkAsProcessed

func (b *SlackMessageStatusTracker) MarkAsProcessed(msgRef *slack.ItemRef)

MarkAsProcessed marks a message as processed by removing the "eyes" reaction and adding the "heavy_check_mark" reaction. If msgRef is nil, no action is performed.

func (*SlackMessageStatusTracker) MarkAsProcessedWithCustomEmoji

func (b *SlackMessageStatusTracker) MarkAsProcessedWithCustomEmoji(msgRef *slack.ItemRef, emoji string)

func (*SlackMessageStatusTracker) MarkAsReceived

func (b *SlackMessageStatusTracker) MarkAsReceived(msgRef *slack.ItemRef)

MarkAsReceived marks a message as received by adding the "eyes" reaction. If msgRef is nil, no action is performed.

type SlackReactionClient

type SlackReactionClient interface {
	AddReaction(name string, item slack.ItemRef) error
	RemoveReaction(name string, item slack.ItemRef) error
}

SlackReactionClient defines the interface for managing reactions on Slack messages.

type SlackRenderer

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

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

func NewSlackRenderer

func NewSlackRenderer() *SlackRenderer

NewSlackRenderer returns new SlackRenderer instance.

func (*SlackRenderer) MessageToMarkdown

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

MessageToMarkdown renders message in Markdown format.

func (*SlackRenderer) RenderAsSlackBlocks

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

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

func (*SlackRenderer) RenderInteractiveMessage

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

RenderInteractiveMessage returns Slack message based on the input msg.

func (*SlackRenderer) RenderModal

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

type SocketSlack

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

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

func NewSocketSlack

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

NewSocketSlack creates a new SocketSlack instance.

func (*SocketSlack) BotName

func (b *SocketSlack) BotName() string

BotName returns the Bot name.

func (*SocketSlack) GetStatus

func (b *SocketSlack) GetStatus() health.PlatformStatus

GetStatus returns the current health status of the SocketSlack bot.

func (*SocketSlack) IntegrationName

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

IntegrationName describes the notifier integration name.

func (*SocketSlack) NotificationsEnabled

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

NotificationsEnabled returns current notification status for a given channel name.

func (*SocketSlack) SendMessage

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

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

SendMessageToAll sends message with interactive sections to all Slack channels.

func (*SocketSlack) SetNotificationsEnabled

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

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

func (*SocketSlack) Start

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

Start starts the Slack WebSocket connection and listens for messages

func (*SocketSlack) Type

Type describes the notifier type.

type Status

type Status struct {
	Status   health.PlatformStatusMsg
	Restarts string
	Reason   health.FailureReasonMsg
}

type TeamsRenderer

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

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

func NewTeamsRenderer

func NewTeamsRenderer() *TeamsRenderer

NewTeamsRenderer return a new TeamsRenderer instance.

func (*TeamsRenderer) MessageToMarkdown

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

MessageToMarkdown renders message in Markdown format.

func (*TeamsRenderer) NonInteractiveSectionToCard

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
Package interactive provides utilities for building interactive bot messages.
Package interactive provides utilities for building interactive bot messages.

Jump to

Keyboard shortcuts

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