slack

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

An Adapter implementation for Slack.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdapter

func NewAdapter(provider data.SlackProvider) adapter.Adapter

NewAdapter will construct a SlackAdapter instance for a given provider configuration.

func ScrubMarkdown

func ScrubMarkdown(text string) string

ScrubMarkdown removes unnecessary/undesirable Slack markdown (of links, of example) from text received from Slack. TODO(mtitmus) Can this be replaced by using Slack's "verbatim text" option?

func Send added in v0.9.0

func Send(ctx context.Context, client *slack.Client, a adapter.Adapter, channelID string, elements templates.OutputElements) error

Send the contents of a response envelope to a specified channel. If channelID is empty the value of envelope.Request.ChannelID will be used.

func SendError added in v0.9.0

func SendError(ctx context.Context, client *slack.Client, channelID string, title string, err error) error

func SendText added in v0.9.0

func SendText(ctx context.Context, client *slack.Client, a adapter.Adapter, channelID string, message string) error

SendText sends a text message to a specified channel. If channelID is empty the value of envelope.Request.ChannelID will be used.

Types

type ClassicAdapter added in v0.8.2

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

ClassicAdapter is the Slack provider implementation of a relay, which knows how to receive events from the Slack API, translate them into Gort events, and forward them along.

func (ClassicAdapter) GetChannelInfo added in v0.8.2

func (s ClassicAdapter) GetChannelInfo(channelID string) (*adapter.ChannelInfo, error)

GetChannelInfo returns the ChannelInfo for a requested channel.

func (ClassicAdapter) GetName added in v0.8.2

func (s ClassicAdapter) GetName() string

GetName returns this adapter's configured name

func (ClassicAdapter) GetPresentChannels added in v0.8.2

func (s ClassicAdapter) GetPresentChannels() ([]*adapter.ChannelInfo, error)

GetPresentChannels returns a slice of channel ID strings that the Adapter is present in. This is expensive. Don't use it often.

func (ClassicAdapter) GetUserInfo added in v0.8.2

func (s ClassicAdapter) GetUserInfo(userID string) (*adapter.UserInfo, error)

GetUserInfo returns the UserInfo for a requested user.

func (ClassicAdapter) Listen added in v0.8.2

func (s ClassicAdapter) Listen(ctx context.Context) <-chan *adapter.ProviderEvent

Listen instructs the relay to begin listening to the provider that it's attached to. It exits immediately, returning a channel that emits ProviderEvents.

func (*ClassicAdapter) Send added in v0.9.0

func (s *ClassicAdapter) Send(ctx context.Context, channelID string, elements templates.OutputElements) error

Send the contents of a response envelope to a specified channel. If channelID is empty the value of envelope.Request.ChannelID will be used.

func (*ClassicAdapter) SendError added in v0.9.0

func (s *ClassicAdapter) SendError(ctx context.Context, channelID string, title string, err error) error

SendError is a break-glass error message function that's used when the templating function fails somehow. Obviously, it does not utilize the templating engine.

func (*ClassicAdapter) SendText added in v0.9.0

func (s *ClassicAdapter) SendText(ctx context.Context, channelID string, message string) error

SendText sends a simple text message to the specified channel.

type SocketModeAdapter added in v0.8.2

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

SocketModeAdapter is the Slack provider implementation of a relay, which knows how to receive events from the Slack API, translate them into Gort events, and forward them along.

func (*SocketModeAdapter) GetChannelInfo added in v0.8.2

func (s *SocketModeAdapter) GetChannelInfo(channelID string) (*adapter.ChannelInfo, error)

GetChannelInfo provides info on a specific provider channel accessible to the adapter.

func (*SocketModeAdapter) GetName added in v0.8.2

func (s *SocketModeAdapter) GetName() string

GetName provides the name of this adapter as per the configuration.

func (*SocketModeAdapter) GetPresentChannels added in v0.8.2

func (s *SocketModeAdapter) GetPresentChannels() ([]*adapter.ChannelInfo, error)

GetPresentChannels returns a slice of channels that a user is present in.

func (*SocketModeAdapter) GetUserInfo added in v0.8.2

func (s *SocketModeAdapter) GetUserInfo(userID string) (*adapter.UserInfo, error)

GetUserInfo provides info on a specific provider user accessible to the adapter.

func (*SocketModeAdapter) Listen added in v0.8.2

func (s *SocketModeAdapter) Listen(ctx context.Context) <-chan *adapter.ProviderEvent

Listen causes the Adapter to initiate a connection to its provider and begin relaying back events (including errors) via the returned channel.

func (*SocketModeAdapter) Send added in v0.9.0

func (s *SocketModeAdapter) Send(ctx context.Context, channelID string, elements templates.OutputElements) error

Send the contents of a response envelope to a specified channel. If channelID is empty the value of envelope.Request.ChannelID will be used.

func (*SocketModeAdapter) SendError added in v0.9.0

func (s *SocketModeAdapter) SendError(ctx context.Context, channelID string, title string, err error) error

SendError is a break-glass error message function that's used when the templating function fails somehow. Obviously, it does not utilize the templating engine.

func (*SocketModeAdapter) SendText added in v0.9.0

func (s *SocketModeAdapter) SendText(ctx context.Context, channelID string, message string) error

SendText sends a simple text message to the specified channel.

Jump to

Keyboard shortcuts

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