Documentation
¶
Overview ¶
Package format renders slio's normalized Message model as either AI-readable Markdown or JSON, onto a writer the caller supplies. It reaches nothing else — no network, no disk: display names and mention resolution arrive through Resolver, which is typically backed by internal/cache and users.info.
Index ¶
- func ParseTs(ts string) (time.Time, error)
- func Ts(t time.Time) string
- func WriteChannels(w io.Writer, f Format, channels []Channel) error
- func WriteMessages(w io.Writer, f Format, messages []Message, resolveUser Resolver, notice string, ...) error
- type Channel
- type FileInfo
- type Format
- type Message
- type NoticePlacement
- type Reaction
- type Resolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ts ¶ added in v1.0.4
Ts converts a time.Time to a Slack ts string, for use as the oldest/latest API parameters.
func WriteChannels ¶ added in v1.0.4
WriteChannels renders channels in the requested format and writes them to w.
func WriteMessages ¶ added in v1.0.4
func WriteMessages(w io.Writer, f Format, messages []Message, resolveUser Resolver, notice string, placement NoticePlacement) error
WriteMessages renders messages in the requested format and writes them to w. A notice (may be "") reports that the list was truncated, and placement says which side of the messages it belongs on.
In JSON mode the placement is ignored: object field order doesn't matter to a consumer, so the notice is one field either way.
Types ¶
type Channel ¶ added in v1.0.4
Channel is one channel in `channel list` output. Unlike Message it needs no rendering pass, so it doubles as the JSON shape rather than having a separate wire type.
type FileInfo ¶
type FileInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Size int64 `json:"size"`
// LocalPath is set only when --download saved the file locally.
LocalPath string `json:"local_path,omitempty"`
}
FileInfo describes a message attachment.
type Format ¶
type Format string
Format is the output format selected by --format. It implements pflag.Value, so a typo is rejected while cobra parses the flags — before the command runs and issues any Slack request.
type Message ¶
type Message struct {
// Ts is the raw Slack timestamp (e.g. "1234567890.123456"), always
// included in JSON output alongside the formatted time so agents can
// build permalinks and follow-up calls.
Ts string
Time time.Time
// Author is a resolved user display name or a bot's
// username/bot_profile.name; formatting treats both the same.
Author string
// Text is the raw mrkdwn message body, transformed by renderText.
Text string
Edited bool
// IsSystem marks a join/leave/etc. message, rendered as a single line.
IsSystem bool
Reactions []Reaction
Files []FileInfo
// ReplyCount and ThreadPermalink are set only for `history` output, on
// messages that have replies.
ReplyCount int
ThreadPermalink string
// Permalink is set only for `search` output, taken directly from the
// API response.
Permalink string
// QuotedBlocks holds bot attachment/block text extracted for
// rendering as blockquotes.
QuotedBlocks []string
// Linked marks the one message a permalink pointed at, set only by
// `thread` (the only command taking a single message's URL).
Linked bool
}
Message is slio's normalized representation of a single Slack message, assembled by the command layer from either conversations.replies/history (which populate ReplyCount/ThreadPermalink) or search.messages (which populates Permalink instead — search.messages reports neither reaction nor reply-count data).
type NoticePlacement ¶ added in v1.0.4
type NoticePlacement int
NoticePlacement says which side of the message list a truncation notice goes on. `history` leads with "older messages omitted" so it is read before the messages it qualifies; `search` trails with "N more results", which only means anything after the results it counts past.
const ( NoticeBeforeMessages NoticePlacement = iota NoticeAfterMessages )
Placements accepted by WriteMessages.