slack

package
v1.16.8 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package slack implements the Slack channel for DevClaw using the Slack Web API and Socket Mode for real-time events — no external dependencies beyond HTTP.

Features:

  • Socket Mode for receiving events (no public URL needed)
  • Send/receive text, images, files
  • Thread support (reply in thread)
  • Reactions (emoji)
  • Typing indicators
  • Channel/DM/group support
  • File upload/download

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// InstanceID identifies this instance ("" for default, e.g. "support" for named).
	// Set automatically from the config key in slack_instances.
	InstanceID string `yaml:"instance_id,omitempty"`

	// BotToken is the Slack Bot User OAuth Token (xoxb-...).
	BotToken string `yaml:"bot_token"`

	// AppToken is the Slack App-Level Token for Socket Mode (xapp-...).
	AppToken string `yaml:"app_token"`

	// AllowedChannels restricts which channel IDs the bot responds in.
	// Empty means respond in all channels.
	AllowedChannels []string `yaml:"allowed_channels"`

	// RespondToThreads enables responding inside threads.
	RespondToThreads bool `yaml:"respond_to_threads"`

	// ReplyInThread always replies in a thread (vs. in-channel).
	ReplyInThread bool `yaml:"reply_in_thread"`

	// SendTyping sends typing indicators while processing.
	SendTyping bool `yaml:"send_typing"`
}

Config holds Slack channel configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Slack

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

Slack implements channels.Channel, channels.MediaChannel, channels.PresenceChannel, and channels.ReactionChannel.

func New

func New(cfg Config, logger *slog.Logger) *Slack

New creates a new Slack channel instance.

func (*Slack) BaseType added in v1.16.0

func (s *Slack) BaseType() string

BaseType returns "slack".

func (*Slack) Connect

func (s *Slack) Connect(ctx context.Context) error

Connect starts the Socket Mode connection for receiving events.

func (*Slack) Disconnect

func (s *Slack) Disconnect() error

Disconnect stops the Socket Mode connection.

func (*Slack) DownloadMedia

func (s *Slack) DownloadMedia(ctx context.Context, msg *channels.IncomingMessage) ([]byte, string, error)

DownloadMedia downloads a file from an incoming message.

func (*Slack) Health

func (s *Slack) Health() channels.HealthStatus

Health returns the channel health status.

func (*Slack) InstanceID added in v1.16.0

func (s *Slack) InstanceID() string

InstanceID returns the instance identifier ("" for default).

func (*Slack) IsConnected

func (s *Slack) IsConnected() bool

IsConnected returns true if the bot is connected.

func (*Slack) MarkRead

func (s *Slack) MarkRead(ctx context.Context, chatID string, messageIDs []string) error

MarkRead marks messages as read in a channel.

func (*Slack) Name

func (s *Slack) Name() string

Name returns the channel name. For the default instance this is "slack"; for named instances it returns "slack:<instance_id>".

func (*Slack) Receive

func (s *Slack) Receive() <-chan *channels.IncomingMessage

Receive returns the incoming messages channel.

func (*Slack) Send

func (s *Slack) Send(ctx context.Context, to string, message *channels.OutgoingMessage) error

Send sends a text message to the specified channel.

func (*Slack) SendMedia

func (s *Slack) SendMedia(ctx context.Context, to string, media *channels.MediaMessage) error

SendMedia sends a file to the specified channel.

func (*Slack) SendPresence

func (s *Slack) SendPresence(ctx context.Context, available bool) error

SendPresence updates the bot's presence.

func (*Slack) SendReaction

func (s *Slack) SendReaction(ctx context.Context, chatID, messageID, emoji string) error

SendReaction adds a reaction emoji to a message.

func (*Slack) SendTyping

func (s *Slack) SendTyping(ctx context.Context, to string) error

SendTyping sends a typing indicator (not directly supported by Slack Web API, but we can use the undocumented endpoint or just skip).

Jump to

Keyboard shortcuts

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