slack

package
v0.0.0-...-8acab51 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package slack provides a Slack bot channel implementation.

Index

Constants

View Source
const SlackAPIBaseURL = "https://slack.com/api"

SlackAPIBaseURL is the base URL for Slack API.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

func New

func New(cfg channel.SlackConfig, logger *zap.Logger) *Channel

func (*Channel) Info

func (c *Channel) Info() channel.Info

func (*Channel) IsConnected

func (c *Channel) IsConnected() bool

func (*Channel) Messages

func (c *Channel) Messages() <-chan channel.Message

func (*Channel) Name

func (c *Channel) Name() string

func (*Channel) OutboundCapabilities

func (c *Channel) OutboundCapabilities() channel.OutboundCapabilities

func (*Channel) RegisterBlockActionHandler

func (c *Channel) RegisterBlockActionHandler(actionID string, handler InteractionHandler)

func (*Channel) RegisterInteractionHandler

func (c *Channel) RegisterInteractionHandler(callbackID string, handler InteractionHandler)

func (*Channel) RespondToInteraction

func (c *Channel) RespondToInteraction(ctx context.Context, responseURL string, msg map[string]interface{}) error

RespondToInteraction sends a response via response URL.

func (*Channel) Send

func (c *Channel) Send(ctx context.Context, msg channel.OutgoingMessage) error

func (*Channel) SendStreaming

func (c *Channel) SendStreaming(ctx context.Context, chatID string, replyToID string, content <-chan string, done chan<- struct{}) error

func (*Channel) SetMessageHandler

func (c *Channel) SetMessageHandler(handler MessageHandler)

func (*Channel) SetSessionManager

func (c *Channel) SetSessionManager(manager *channel.BotSessionManager)

func (*Channel) Start

func (c *Channel) Start(ctx context.Context) error

func (*Channel) Stop

func (c *Channel) Stop(ctx context.Context) error

func (*Channel) Type

func (c *Channel) Type() string

func (*Channel) WebhookHandler

func (c *Channel) WebhookHandler() http.HandlerFunc

WebhookHandler returns an HTTP handler for webhook events.

type InteractionAction

type InteractionAction struct {
	ActionID        string                      `json:"action_id"`
	BlockID         string                      `json:"block_id"`
	Type            string                      `json:"type"`
	Value           string                      `json:"value"`
	SelectedOption  InteractionSelectedOption   `json:"selected_option"`
	SelectedOptions []InteractionSelectedOption `json:"selected_options"`
}

InteractionAction represents a single action in a Slack interaction payload.

type InteractionCallback

type InteractionCallback struct {
	Type        string `json:"type"`
	TriggerID   string `json:"trigger_id"`
	CallbackID  string `json:"callback_id"`
	ResponseURL string `json:"response_url"`
	Channel     struct {
		ID string `json:"id"`
	} `json:"channel"`
	User struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"user"`
	View struct {
		CallbackID string `json:"callback_id"`
	} `json:"view"`
	Actions []InteractionAction `json:"actions"`
}

InteractionCallback represents a Slack interaction payload.

type InteractionHandler

type InteractionHandler func(ctx context.Context, callback *InteractionCallback) error

type InteractionSelectedOption

type InteractionSelectedOption struct {
	Value string `json:"value"`
}

InteractionSelectedOption represents a selected option in a Slack interaction.

type MessageHandler

type MessageHandler func(ctx context.Context, msg channel.Message) (string, error)

type Validator

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

Validator validates Slack bot configuration by calling the auth.test API.

func NewValidator

func NewValidator() *Validator

NewValidator creates a new Slack validator.

func NewValidatorWithOptions

func NewValidatorWithOptions(timeout time.Duration, baseURL string) *Validator

NewValidatorWithOptions creates a new Slack validator with custom options.

func NewValidatorWithTimeout

func NewValidatorWithTimeout(timeout time.Duration) *Validator

NewValidatorWithTimeout creates a new Slack validator with custom timeout.

func (*Validator) Validate

func (v *Validator) Validate(ctx context.Context, config map[string]string) validator.Result

Validate tests the Slack bot connection by calling auth.test API.

Jump to

Keyboard shortcuts

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