Documentation
¶
Index ¶
- func FormatMrkdwn(text string) string
- type ApprovalProvider
- type Block
- type Channel
- func (c *Channel) GetApprovalProvider() *ApprovalProvider
- func (c *Channel) Name() string
- func (c *Channel) Send(channelID string, msg *OutgoingMessage) error
- func (c *Channel) SetHandler(handler MessageHandler)
- func (c *Channel) Start(ctx context.Context) error
- func (c *Channel) StartTyping(channelID string) func()
- func (c *Channel) Stop(ctx context.Context) error
- type Client
- type Config
- type IncomingMessage
- type MessageHandler
- type OutgoingMessage
- type SlackClient
- type SlackSocket
- type Socket
- type TextBlock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatMrkdwn ¶
FormatMrkdwn converts standard Markdown to Slack mrkdwn format.
Conversions:
- **bold** → *bold*
- ~~strike~~ → ~strike~
- [text](url) → <url|text>
- # Heading → *Heading*
Content inside code blocks (```) is preserved without transformation.
Types ¶
type ApprovalProvider ¶
type ApprovalProvider struct {
// contains filtered or unexported fields
}
ApprovalProvider implements approval.Provider for Slack using Block Kit action buttons.
func NewApprovalProvider ¶
func NewApprovalProvider(api Client, timeout time.Duration) *ApprovalProvider
NewApprovalProvider creates a Slack approval provider.
func (*ApprovalProvider) CanHandle ¶
func (p *ApprovalProvider) CanHandle(sessionKey string) bool
CanHandle returns true for session keys starting with "slack:".
func (*ApprovalProvider) HandleInteractive ¶
func (p *ApprovalProvider) HandleInteractive(actionID string)
HandleInteractive processes a Slack interactive callback (block_actions) for approval.
func (*ApprovalProvider) RequestApproval ¶
func (p *ApprovalProvider) RequestApproval(ctx context.Context, req approval.ApprovalRequest) (approval.ApprovalResponse, error)
RequestApproval posts a message with approve/deny/always-allow action buttons and waits for interaction.
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel implements Slack bot
func (*Channel) GetApprovalProvider ¶
func (c *Channel) GetApprovalProvider() *ApprovalProvider
GetApprovalProvider returns the channel's approval provider for composite registration.
func (*Channel) Send ¶
func (c *Channel) Send(channelID string, msg *OutgoingMessage) error
Send sends a message. Standard Markdown in msg.Text is auto-converted to Slack mrkdwn before sending.
func (*Channel) SetHandler ¶
func (c *Channel) SetHandler(handler MessageHandler)
SetHandler sets the message handler
func (*Channel) StartTyping ¶
StartTyping posts a "_Processing..._ " placeholder message. The returned stop function deletes the placeholder on call. If posting fails, a no-op stop function is returned.
type Client ¶
type Client interface {
AuthTest() (*slack.AuthTestResponse, error)
PostMessage(channelID string, options ...slack.MsgOption) (string, string, error)
UpdateMessage(channelID, timestamp string, options ...slack.MsgOption) (string, string, string, error)
DeleteMessage(channelID, messageTimestamp string) (string, string, error)
}
Client defines the interface for Slack REST API operations.
type Config ¶
type Config struct {
BotToken string // xoxb-...
AppToken string // xapp-... (for Socket Mode)
SigningSecret string
ApprovalTimeoutSec int // 0 = default 30s
APIURL string // optional, for testing
HTTPClient *http.Client // optional, for testing
Client Client // optional, for testing
Socket Socket // optional, for testing
}
Config holds Slack channel configuration
type IncomingMessage ¶
type IncomingMessage struct {
EventType string // app_mention, message
ChannelID string
UserID string
Text string
ThreadTS string
IsThread bool
}
IncomingMessage represents a message from Slack
type MessageHandler ¶
type MessageHandler func(ctx context.Context, msg *IncomingMessage) (*OutgoingMessage, error)
MessageHandler handles incoming messages
type OutgoingMessage ¶
OutgoingMessage represents a message to send
type SlackClient ¶
SlackClient is an adapter for *slack.Client.
func NewSlackClient ¶
func NewSlackClient(c *slack.Client) *SlackClient
NewSlackClient creates a new SlackClient adapter.
type SlackSocket ¶
type SlackSocket struct {
*socketmode.Client
}
SlackSocket is an adapter for *socketmode.Client.
func NewSlackSocket ¶
func NewSlackSocket(c *socketmode.Client) *SlackSocket
NewSlackSocket creates a new SlackSocket adapter.
func (*SlackSocket) Events ¶
func (s *SlackSocket) Events() <-chan socketmode.Event
Events returns the events channel.
type Socket ¶
type Socket interface {
Run() error
Ack(req socketmode.Request, payload ...interface{})
Events() <-chan socketmode.Event
}
Socket defines the interface for Slack Socket Mode operations.