slack

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package slack is a minimal Slack Web API client for zen's Slack task watcher. It only implements the handful of methods the watcher needs (reactions.list, conversations.replies, reactions.add, chat.postMessage, chat.getPermalink, auth.test) — it is not a general-purpose Slack SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Method string
	Code   string
}

APIError is returned when Slack responds with {"ok": false}.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

Client is a thin wrapper around the Slack Web API, authenticated with a single user token (scopes: reactions:read, channels:history, groups:history, im:history, mpim:history, chat:write).

func NewClient

func NewClient(token string) *Client

NewClient creates a Slack API client authenticated with token.

func (*Client) AddReaction

func (c *Client) AddReaction(ctx context.Context, channel, ts, name string) error

AddReaction adds a reaction to a message. Slack's "already_reacted" error is treated as success — idempotent under daemon restarts re-processing the same message.

func (*Client) AuthTest

func (c *Client) AuthTest(ctx context.Context) (userID string, err error)

AuthTest returns the Slack user ID the token authenticates as.

func (*Client) ConversationsReplies

func (c *Client) ConversationsReplies(ctx context.Context, channel, ts string) ([]Message, error)

ConversationsReplies returns the parent message plus all replies in a thread.

func (*Client) HasReaction

func (c *Client) HasReaction(ctx context.Context, channel, ts, name string) (bool, error)

HasReaction reports whether a message already carries a reaction named name.

func (*Client) ListReactions

func (c *Client) ListReactions(ctx context.Context, emoji string, maxPages int) ([]ReactionHit, error)

ListReactions pages through reactions.list for the authenticated user and returns every message that carries a reaction named emoji, across up to maxPages pages of 100 items each. reactions.list documents no sort order or since-timestamp filter, so callers must dedupe against their own seen-set rather than relying on pagination order or an early cutoff.

func (c *Client) Permalink(ctx context.Context, channel, ts string) (string, error)

Permalink returns the permalink URL for a message.

func (*Client) PostMessage

func (c *Client) PostMessage(ctx context.Context, channel, text string) error

PostMessage sends a message to a channel or, when channel is a user ID, a direct message to that user.

type Message

type Message struct {
	User string `json:"user"`
	Text string `json:"text"`
	Ts   string `json:"ts"`
}

Message is a single Slack message, as returned by conversations.replies.

type Reaction

type Reaction struct {
	Name  string   `json:"name"`
	Count int      `json:"count"`
	Users []string `json:"users"`
}

Reaction is a single named reaction on a message, with the count and users who added it.

type ReactionHit

type ReactionHit struct {
	ChannelID string
	MessageTS string
}

ReactionHit identifies a message carrying the emoji ListReactions searched for.

Jump to

Keyboard shortcuts

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