Documentation
¶
Overview ¶
Package slack implements a slack adapter for the joe bot library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BotAdapter ¶
type BotAdapter struct {
// contains filtered or unexported fields
}
BotAdapter implements a joe.Adapter that reads and writes messages to and from Slack.
func NewAdapter ¶
func NewAdapter(ctx context.Context, conf Config) (*BotAdapter, error)
NewAdapter creates a new *BotAdapter that connects to Slack. Note that you will usually configure the slack adapter as joe.Module (i.e. using the Adapter function of this package).
func (*BotAdapter) Close ¶
func (a *BotAdapter) Close() error
Close disconnects the adapter from the slack API.
func (*BotAdapter) React ¶ added in v0.7.0
React implements joe.ReactionAwareAdapter by letting the bot attach the given reaction to the message.
func (*BotAdapter) RegisterAt ¶
func (a *BotAdapter) RegisterAt(brain *joe.Brain)
RegisterAt implements the joe.Adapter interface by emitting the slack API events to the given brain.
func (*BotAdapter) Send ¶
func (a *BotAdapter) Send(text, channelID string) error
Send implements joe.Adapter by sending all received text messages to the given slack channel ID.
type Config ¶
type Config struct { Token string Name string Debug bool Logger *zap.Logger // SendMsgParams contains settings that are applied to all messages sent // by the BotAdapter. SendMsgParams slack.PostMessageParameters // Log unknown message types as error message for debugging. This option is // disabled by default. LogUnknownMessageTypes bool // Listen and respond to all messages not just those directed at the Bot User. ListenPassive bool }
Config contains the configuration of a BotAdapter.
type Option ¶
An Option is used to configure the slack adapter.
func WithListenPassive ¶ added in v0.9.0
func WithListenPassive() Option
WithListenPassive makes the adapter listen and respond to all messages not just those directed at it
func WithLogUnknownMessageTypes ¶ added in v0.8.0
func WithLogUnknownMessageTypes() Option
WithLogUnknownMessageTypes makes the adapter log unknown message types as error message for debugging. This option is disabled by default.
func WithLogger ¶
WithLogger can be used to inject a different logger for the slack adapater.
func WithMessageParams ¶ added in v0.5.0
func WithMessageParams(params slack.PostMessageParameters) Option
WithMessageParams overrides the default parameters that are used when sending any message to slack.