slackchat

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package slackchat connects initech to Slack via Socket Mode. It receives @mention events from Slack and dispatches them to agent panes. The client is started as a goroutine from TUI.Run() when Slack tokens are configured.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMention

func ParseMention(text string) (agent, body string)

ParseMention strips the <@BOTID> prefix from Slack message text and extracts the agent name (first word, lowercased) and message body (rest). Returns empty strings when the input has no content after the mention.

Types

type AgentHost

type AgentHost interface {
	// FindAgent returns info for the named agent, or false if not found.
	FindAgent(name string) (AgentInfo, bool)

	// AllAgents returns info for all managed agents.
	AllAgents() []AgentInfo

	// SendToAgent delivers text to the named agent's PTY (with Enter).
	// Returns an error if the agent is not found.
	SendToAgent(name, text string) error
}

AgentHost provides agent lookup and delivery for Slack dispatch. Implemented by the TUI bridge adapter.

type AgentInfo

type AgentInfo struct {
	Name     string
	Alive    bool
	Activity string
}

AgentInfo describes a running agent for Slack replies.

type Client

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

Client manages the Slack Socket Mode connection and event loop.

func NewClient

func NewClient(appToken, botToken string, host AgentHost, logger *slog.Logger) *Client

NewClient creates a Slack client configured for Socket Mode. The appToken (xapp-...) is used to establish the WebSocket connection. The botToken (xoxb-...) is used for Web API calls (posting messages, adding reactions). The host provides agent lookup and delivery; pass nil to defer wiring.

func (*Client) Run

func (c *Client) Run(ctx context.Context)

Run connects to Slack via Socket Mode and processes events until the context is cancelled. It blocks, so call it in a goroutine. Reconnection is handled automatically by the slack-go library.

Jump to

Keyboard shortcuts

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