Documentation
¶
Index ¶
- Constants
- type Adapter
- func (a *Adapter) AddReaction(ctx context.Context, reaction base.Reaction) error
- func (a *Adapter) SendAttachment(ctx context.Context, channelID, threadTS string, attachment base.Attachment) error
- func (a *Adapter) SendMessage(ctx context.Context, sessionID string, msg *base.ChatMessage) error
- func (a *Adapter) SendMessageWithOptions(ctx context.Context, sessionID string, msg *MessageContent, ...) error
- func (a *Adapter) SendToChannel(ctx context.Context, channelID, text, threadTS string) error
- func (a *Adapter) SetSender(fn func(ctx context.Context, sessionID string, msg *base.ChatMessage) error)
- func (a *Adapter) SetSlashCommandHandler(fn func(cmd SlashCommand))
- func (a *Adapter) Start(ctx context.Context) error
- func (a *Adapter) Stop() error
- type Config
- type Event
- type EventHandler
- type MessageContent
- type MessageEvent
- type RetryConfig
- type SendMessageOptions
- type SlashCommand
- type SocketModeConfig
- type SocketModeConnection
- func (s *SocketModeConnection) IsConnected() bool
- func (s *SocketModeConnection) RegisterHandler(eventType string, handler EventHandler)
- func (s *SocketModeConnection) Send(data map[string]any) error
- func (s *SocketModeConnection) SetReconnectCallbacks(onReconnect func(), onReconnectFail func(error))
- func (s *SocketModeConnection) Start(ctx context.Context) error
- func (s *SocketModeConnection) Stop() error
Constants ¶
const SlackTextLimit = 4000
SlackTextLimit is the maximum character limit for a single Slack message
const SocketModeURL = "wss://wss.slack.com/ws"
SocketModeURL is the Slack Socket Mode WebSocket endpoint
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
func NewAdapter ¶
func (*Adapter) AddReaction ¶ added in v0.11.1
AddReaction adds a reaction to a message
func (*Adapter) SendAttachment ¶
func (a *Adapter) SendAttachment(ctx context.Context, channelID, threadTS string, attachment base.Attachment) error
SendAttachment sends an attachment to a Slack channel
func (*Adapter) SendMessage ¶
func (*Adapter) SendMessageWithOptions ¶
func (a *Adapter) SendMessageWithOptions(ctx context.Context, sessionID string, msg *MessageContent, opts SendMessageOptions) error
SendMessageWithOptions sends a message with full options support This includes: message chunking, thread support, rate limiting
func (*Adapter) SendToChannel ¶
func (*Adapter) SetSlashCommandHandler ¶ added in v0.11.1
func (a *Adapter) SetSlashCommandHandler(fn func(cmd SlashCommand))
SetSlashCommandHandler sets the handler for slash commands
type Config ¶
type Config struct {
BotToken string
AppToken string
SigningSecret string
SystemPrompt string
// Mode: "http" (default) or "socket" for WebSocket connection
Mode string
// ServerAddr: HTTP server address (e.g., ":8080")
ServerAddr string
}
func (*Config) IsSocketMode ¶
IsSocketMode returns true if Socket Mode is enabled
type EventHandler ¶
type EventHandler func(eventType string, data json.RawMessage)
EventHandler handles incoming Slack events
type MessageContent ¶
type MessageContent struct {
Content string
}
MessageContent represents the content of a message to send
type MessageEvent ¶
type MessageEvent struct {
Type string `json:"type"`
Channel string `json:"channel"`
ChannelType string `json:"channel_type"`
User string `json:"user"`
Text string `json:"text"`
TS string `json:"ts"`
EventTS string `json:"event_ts"`
BotID string `json:"bot_id,omitempty"`
SubType string `json:"subtype,omitempty"`
ThreadTS string `json:"thread_ts,omitempty"` // Thread identifier
ParentUser string `json:"parent_user_id,omitempty"` // Parent message user
}
type RetryConfig ¶
RetryConfig configures the retry behavior
type SendMessageOptions ¶
type SendMessageOptions struct {
ChannelID string
ThreadTS string
Markdown bool // Whether to convert markdown to mrkdwn
}
SendMessageOptions contains options for sending messages
type SlashCommand ¶ added in v0.11.1
type SlashCommand struct {
Command string
Text string
UserID string
ChannelID string
ResponseURL string
}
SlashCommand represents a Slack slash command
type SocketModeConfig ¶
SocketModeConfig holds configuration for Socket Mode connection
type SocketModeConnection ¶
type SocketModeConnection struct {
// contains filtered or unexported fields
}
SocketModeConnection manages a WebSocket connection to Slack's Socket Mode
func NewSocketModeConnection ¶
func NewSocketModeConnection(config SocketModeConfig, logger *slog.Logger) *SocketModeConnection
NewSocketModeConnection creates a new Socket Mode connection
func (*SocketModeConnection) IsConnected ¶
func (s *SocketModeConnection) IsConnected() bool
IsConnected returns true if the connection is active
func (*SocketModeConnection) RegisterHandler ¶
func (s *SocketModeConnection) RegisterHandler(eventType string, handler EventHandler)
RegisterHandler registers an event handler for a specific event type
func (*SocketModeConnection) Send ¶
func (s *SocketModeConnection) Send(data map[string]any) error
Send sends a message over the WebSocket connection
func (*SocketModeConnection) SetReconnectCallbacks ¶ added in v0.11.2
func (s *SocketModeConnection) SetReconnectCallbacks(onReconnect func(), onReconnectFail func(error))
SetReconnectCallbacks sets callbacks for reconnection events
func (*SocketModeConnection) Start ¶
func (s *SocketModeConnection) Start(ctx context.Context) error
Start begins the Socket Mode connection
func (*SocketModeConnection) Stop ¶
func (s *SocketModeConnection) Stop() error
Stop closes the Socket Mode connection