slack

package
v0.12.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package slack provides the Slack implementation of the communication interface.

Index

Constants

View Source
const (
	ReactionRunning = "hourglass_flowing_sand"
	ReactionError   = "x"
	ReactionOK      = "white_check_mark"
)

Bot reactions.

View Source
const CommunicationType = "slack"

CommunicationType defines a workspace type.

Variables

This section is empty.

Functions

func AppMentionEventToIncomingMessage

func AppMentionEventToIncomingMessage(event *slackevents.AppMentionEvent) models.IncomingMessage

AppMentionEventToIncomingMessage converts a Slack application mention event to the standard incoming message.

func MessageEventToIncomingMessage

func MessageEventToIncomingMessage(event *slackevents.MessageEvent) models.IncomingMessage

MessageEventToIncomingMessage converts a Slack message event to the standard incoming message.

Types

type Assistant

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

Assistant provides a service for interaction with a communication channel.

func NewAssistant

func NewAssistant(cfg *config.Credentials, appCfg *config.Config, handlerPrefix string, pack *features.Pack,
	platformClient *platform.Client, sessionStorage storage.SessionStorage) *Assistant

NewAssistant returns a new assistant service.

func (*Assistant) AddChannel

func (a *Assistant) AddChannel(channelID string, dbLabInstance *dblab.Instance)

AddChannel sets a message processor for a specific channel.

func (*Assistant) CheckIdleSessions

func (a *Assistant) CheckIdleSessions(ctx context.Context)

CheckIdleSessions check the running user sessions for idleness.

func (*Assistant) Deregister

func (a *Assistant) Deregister(_ context.Context) error

Deregister deregisters the assistant service.

func (*Assistant) DumpSessions

func (a *Assistant) DumpSessions()

DumpSessions collects user's data from every message processor to sessionStorage.

func (*Assistant) Init

func (a *Assistant) Init() error

Init initializes assistant handlers.

func (*Assistant) Register

func (a *Assistant) Register(_ context.Context) error

Register registers the assistant service.

func (*Assistant) RestoreSessions

func (a *Assistant) RestoreSessions(ctx context.Context) error

RestoreSessions checks sessions after restart and establishes DB connection.

type MessageValidator

type MessageValidator struct {
}

MessageValidator validates incoming messages.

func (MessageValidator) Validate

func (mv MessageValidator) Validate(incomingMessage *models.IncomingMessage) error

Validate validates an incoming message.

type Messenger

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

Messenger provides a communication via Slack API.

func NewMessenger

func NewMessenger(api *slack.Client, cfg *MessengerConfig) *Messenger

NewMessenger creates a new Slack messenger service.

func (*Messenger) AddArtifact

func (m *Messenger) AddArtifact(title, explainResult, channelID, messageID string) (string, error)

AddArtifact uploads artifacts to a communication channel.

func (*Messenger) DownloadArtifact

func (m *Messenger) DownloadArtifact(privateURL string) ([]byte, error)

DownloadArtifact downloads snippets from a communication channel.

func (*Messenger) Fail

func (m *Messenger) Fail(message *models.Message, text string) error

Fail finishes the communication and marks message as failed.

func (*Messenger) OK

func (m *Messenger) OK(message *models.Message) error

OK finishes the communication and marks message as succeeding.

func (*Messenger) Publish

func (m *Messenger) Publish(message *models.Message) error

Publish posts messages.

func (*Messenger) UpdateStatus

func (m *Messenger) UpdateStatus(message *models.Message, status models.MessageStatus) error

UpdateStatus updates message reactions.

func (*Messenger) UpdateText

func (m *Messenger) UpdateText(message *models.Message) error

UpdateText updates a message text.

type MessengerConfig

type MessengerConfig struct {
	AccessToken string
}

MessengerConfig defines a slack configuration parameters.

type UserInformer

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

UserInformer provides a service for getting user info.

func NewUserInformer

func NewUserInformer(api *slack.Client) *UserInformer

NewUserInformer creates a new UserInformer service.

func (*UserInformer) GetUserInfo

func (m *UserInformer) GetUserInfo(userID string) (models.UserInfo, error)

GetUserInfo retrieves user info by ID.

Jump to

Keyboard shortcuts

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