slack

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package slack is tomo's Slack channel. It runs in socket mode, so there is no public request URL to host: an app-level token opens a websocket, events arrive over it, and each is acknowledged by its envelope id. Messages are sent with a bot token over the web API. Only allowlisted channels are served, and approvals render as Block Kit buttons.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Slack

type Slack struct {
	AppToken string   // xapp-... , opens the socket
	BotToken string   // xoxb-... , posts messages
	Allow    []string // channel ids permitted to talk to the bot
	BaseURL  string   // web API base, default https://slack.com/api
	Client   *http.Client

	// Dial connects the socket. Nil uses websocket.Dial; tests override it.
	Dial func(ctx context.Context, url string) (*websocket.Conn, error)
	// contains filtered or unexported fields
}

Slack serves an allowlisted set of channels over a socket-mode connection.

func (*Slack) Caps

func (s *Slack) Caps() channel.Caps

Caps implements channel.Channel. Slack carries files and renders buttons.

func (*Slack) Name

func (s *Slack) Name() string

Name implements channel.Channel.

func (*Slack) Post

func (s *Slack) Post(ctx context.Context, chat, text string) error

Post pushes a message to a channel outside a reply, for scheduled runs. It implements schedule.Poster.

func (*Slack) Run

func (s *Slack) Run(ctx context.Context, h channel.Handler) error

Run opens a socket, serves it until it drops, and reconnects with a short backoff, until ctx is cancelled.

Jump to

Keyboard shortcuts

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