Documentation
¶
Overview ¶
Package slackclient wraps github.com/slack-go/slack with the deadline and rate-limit handling slio's commands need: every call runs against a caller-supplied context and, on HTTP 429, retries honoring Retry-After as long as the context's deadline allows.
Index ¶
- type AuthTestResult
- type Client
- func (c *Client) AuthTest(ctx context.Context) (AuthTestResult, error)
- func (c *Client) ConversationHistory(ctx context.Context, channel, oldest, latest string, limit int) (messages []slack.Message, hasMore bool, err error)
- func (c *Client) ConversationReplies(ctx context.Context, channel, ts string) ([]slack.Message, error)
- func (c *Client) ConversationsForUser(ctx context.Context) ([]slack.Channel, error)
- func (c *Client) DownloadFile(ctx context.Context, urlPrivate, destPath string) error
- func (c *Client) GetUserInfo(ctx context.Context, userID string) (*slack.User, error)
- func (c *Client) SearchMessages(ctx context.Context, query string, limit int) (matches []slack.SearchMessage, total int, err error)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthTestResult ¶
type AuthTestResult struct {
// Host is the workspace's host (e.g. "myws.slack.com"), used both to
// record a profile's workspace and to build thread permalinks.
Host string
// TeamID keys the local cache when SLIO_TOKEN bypasses profile
// resolution and no profile name is available.
TeamID string
}
AuthTestResult is the subset of auth.test's response slio needs.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a deadline- and retry-aware wrapper around *slack.Client.
func (*Client) AuthTest ¶
func (c *Client) AuthTest(ctx context.Context) (AuthTestResult, error)
AuthTest verifies the client's token and reports the workspace it belongs to.
func (*Client) ConversationHistory ¶
func (c *Client) ConversationHistory(ctx context.Context, channel, oldest, latest string, limit int) (messages []slack.Message, hasMore bool, err error)
ConversationHistory fetches up to limit of the most recent messages in a channel (optionally bounded by oldest/latest, both Slack ts strings, or "" for no bound), following cursor pagination as needed. hasMore reports whether more messages exist beyond what was returned, so callers can show an "older messages omitted" notice; it's determined by asking for one extra message and dropping it if present, rather than trusting Slack's has_more on the exact boundary page.
func (*Client) ConversationReplies ¶
func (c *Client) ConversationReplies(ctx context.Context, channel, ts string) ([]slack.Message, error)
ConversationReplies fetches every message in a thread (the parent plus all replies), following cursor pagination until Slack reports no more.
func (*Client) ConversationsForUser ¶
ConversationsForUser lists the public and private channels the token's user is a member of, excluding archived ones, following cursor pagination. conversations.list can't filter by membership, hence users.conversations here instead.
func (*Client) DownloadFile ¶
DownloadFile downloads a Slack file's contents from its url_private, authenticating with the client's own token (url_private requires a bearer token; slio must do the download itself, since only it holds the token), and writes it to destPath. Slack returns an HTML sign-in page with HTTP 200 rather than an error when the token lacks files:read, so that case is detected via Content-Type and reported explicitly rather than silently saving the wrong content.
func (*Client) GetUserInfo ¶
GetUserInfo fetches a user's profile, for resolving display names.
func (*Client) SearchMessages ¶
func (c *Client) SearchMessages(ctx context.Context, query string, limit int) (matches []slack.SearchMessage, total int, err error)
SearchMessages searches messages, following Slack's page-number-based pagination (search.messages has no cursor) until limit results are collected or no more pages remain. total is the API's reported total hit count, for the "N more results" notice.