format

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentList

func AgentList(agents []AgentInfo, currentBotUserID string) string

AgentList formats discovered agents as a numbered list for LLM-facing text. When currentBotUserID matches an agent's ID, a marker line is added for that row.

func AuthoredPost

func AuthoredPost(post *model.Post, username string) string

AuthoredPost formats a post body with the username of its author for LLM consumption.

func BuildPostIndex

func BuildPostIndex(posts []*model.Post) map[string]int

BuildPostIndex creates a map from post ID to its 1-based display index. Used to generate "(reply to Post N)" annotations.

func MemberRole

func MemberRole(schemeAdmin, schemeGuest, schemeUser bool) string

MemberRole converts scheme booleans to a readable role string. Works for both channel and team members.

func PostBody

func PostBody(post *model.Post) string

func ThreadData

func ThreadData(data *mmapi.ThreadData) string

func WriteBookmark

func WriteBookmark(w *strings.Builder, entry BookmarkEntry)

WriteBookmark writes a formatted channel bookmark entry to the builder.

func WriteBot

func WriteBot(w *strings.Builder, entry BotEntry)

WriteBot writes a bot account's details to the builder.

func WriteCPAField

func WriteCPAField(w *strings.Builder, entry CPAFieldEntry)

WriteCPAField writes a Custom Profile Attribute field definition to the builder.

func WriteChannel

func WriteChannel(w *strings.Builder, entry ChannelEntry)

WriteChannel writes a formatted channel entry to the builder.

func WriteChannelMember

func WriteChannelMember(w *strings.Builder, entry ChannelMemberEntry)

WriteChannelMember writes a channel membership record (roles, mute, last-viewed).

func WriteChannelModerations

func WriteChannelModerations(w *strings.Builder, moderations []*model.ChannelModeration)

WriteChannelModerations writes a channel's moderation settings to the builder.

func WriteChannelStats

func WriteChannelStats(w *strings.Builder, stats *model.ChannelStats)

WriteChannelStats writes a channel's statistics to the builder.

func WriteChannelUnread

func WriteChannelUnread(w *strings.Builder, unread *model.ChannelUnread)

WriteChannelUnread writes a channel's unread counts to the builder.

func WriteCustomStatus

func WriteCustomStatus(w *strings.Builder, userID string, cs *model.CustomStatus)

WriteCustomStatus writes a user's custom status (emoji + text + expiry).

func WriteEmoji

func WriteEmoji(w *strings.Builder, entry EmojiEntry)

WriteEmoji writes a formatted custom emoji entry to the builder.

func WriteFileDescriptor

func WriteFileDescriptor(w *strings.Builder, entry FileDescriptorEntry)

WriteFileDescriptor writes a compact file metadata descriptor to the builder.

func WriteGroup

func WriteGroup(w *strings.Builder, entry GroupEntry)

WriteGroup writes a group's metadata to the builder.

func WriteIncomingWebhook

func WriteIncomingWebhook(w *strings.Builder, entry IncomingWebhookEntry)

WriteIncomingWebhook writes an incoming webhook's details to the builder.

func WriteOutgoingWebhook

func WriteOutgoingWebhook(w *strings.Builder, entry OutgoingWebhookEntry)

WriteOutgoingWebhook writes an outgoing webhook's details to the builder.

func WritePost

func WritePost(w *strings.Builder, entry PostEntry)

FormatPost writes a single formatted post entry to the builder.

func WritePostInfo

func WritePostInfo(w *strings.Builder, entry PostInfoEntry)

WritePostInfo writes a post's channel/team context metadata to the builder.

func WriteReactions

func WriteReactions(w *strings.Builder, postID string, reactions []*model.Reaction, usernames map[string]string)

WriteReactions writes a post's emoji reactions grouped by emoji, with the reacting usernames, to the builder. usernames maps user IDs to usernames.

func WriteRole

func WriteRole(w *strings.Builder, entry RoleEntry)

WriteRole writes a role definition and its permissions to the builder.

func WriteScheduledPost

func WriteScheduledPost(w *strings.Builder, entry ScheduledPostEntry)

WriteScheduledPost writes a formatted scheduled post entry to the builder.

func WriteSidebarCategory

func WriteSidebarCategory(w *strings.Builder, entry SidebarCategoryEntry)

WriteSidebarCategory writes a sidebar category and its channel IDs to the builder.

func WriteStatus

func WriteStatus(w *strings.Builder, entry StatusEntry)

WriteStatus writes a user's presence status to the builder.

func WriteTeam

func WriteTeam(w *strings.Builder, entry TeamEntry)

WriteTeam writes a formatted team entry to the builder.

func WriteTeamMember

func WriteTeamMember(w *strings.Builder, entry TeamMemberEntry)

WriteTeamMember writes a team membership record (roles) to the builder.

func WriteTeamStats

func WriteTeamStats(w *strings.Builder, stats *model.TeamStats)

WriteTeamStats writes a team's member statistics to the builder.

func WriteTeamUnread

func WriteTeamUnread(w *strings.Builder, unread *model.TeamUnread)

WriteTeamUnread writes a single team's unread counts to the builder.

func WriteThreadSummary

func WriteThreadSummary(w *strings.Builder, entry ThreadSummaryEntry)

WriteThreadSummary writes a collated-thread summary to the builder.

func WriteUser

func WriteUser(w *strings.Builder, entry UserEntry)

WriteUser writes a formatted user entry to the builder.

Types

type AgentInfo

type AgentInfo struct {
	ID          string
	DisplayName string
	Username    string
}

AgentInfo holds display fields for formatting an AI agent list (e.g. MCP tool output).

type BookmarkEntry

type BookmarkEntry struct {
	HeaderLabel string
	Bookmark    *model.ChannelBookmarkWithFileInfo
}

BookmarkEntry holds data for formatting a single channel bookmark.

type BotEntry

type BotEntry struct {
	HeaderLabel string
	Bot         *model.Bot
}

BotEntry holds data for formatting a single bot account.

type CPAFieldEntry

type CPAFieldEntry struct {
	HeaderLabel string
	Field       *model.PropertyField
}

CPAFieldEntry holds data for formatting a single Custom Profile Attribute field.

type ChannelEntry

type ChannelEntry struct {
	HeaderLabel string         // e.g. "Channel Information:", "1. **General**"; empty to omit
	Channel     *model.Channel // the source channel
	TeamName    string         // resolved team display name
	TeamID      string         // team ID (shown when TeamName is empty but TeamID is set)
	MemberCount int64          // -1 means don't show
	Role        string         // requesting user's role: "admin" | "member" | "guest" | "not_member" | "" (omit)
}

ChannelEntry holds data for formatting a single channel.

type ChannelMemberEntry

type ChannelMemberEntry struct {
	HeaderLabel string
	Member      *model.ChannelMember
	Username    string // resolved, optional
}

ChannelMemberEntry holds data for formatting a single channel membership record.

type EmojiEntry

type EmojiEntry struct {
	HeaderLabel string
	Emoji       *model.Emoji
	CreatorName string
}

EmojiEntry holds data for formatting a single custom emoji.

type FileDescriptorEntry

type FileDescriptorEntry struct {
	// Number is the 1-based position of the file in the attachment list; it
	// renders as an "Attached File N" header. A zero value omits the header.
	Number   int
	FileInfo *model.FileInfo // the source file
}

FileDescriptorEntry holds metadata for a file attachment surfaced to the LLM without inlining its contents. The File ID is included so the model can pass it to the read_file tool to fetch the contents on demand.

type GroupEntry

type GroupEntry struct {
	HeaderLabel string
	Group       *model.Group
}

GroupEntry holds data for formatting a single group.

type IncomingWebhookEntry

type IncomingWebhookEntry struct {
	HeaderLabel string
	Webhook     *model.IncomingWebhook
}

IncomingWebhookEntry holds data for formatting an incoming webhook.

type OutgoingWebhookEntry

type OutgoingWebhookEntry struct {
	HeaderLabel string
	Webhook     *model.OutgoingWebhook
}

OutgoingWebhookEntry holds data for formatting an outgoing webhook.

type PostEntry

type PostEntry struct {
	// Header components
	HeaderLabel     string  // e.g. "Post 1", "Result 3"
	Username        string  // resolved username; "" → "Unknown User"
	Score           float32 // >0 means show "(Score: X.XX)" — search only
	ReplyAnnotation string  // e.g. "(reply to Post 2)" — appended to header

	// The source post
	Post *model.Post

	// Optional context metadata (search results show per-result channel info)
	ChannelName string
	TeamName    string
	ShowChannel bool // show Channel ID line

}

PostEntry holds pre-resolved data for formatting a single post. Used by MCP tools and other callers that need structured post output.

type PostInfoEntry

type PostInfoEntry struct {
	PostID   string
	PostInfo *model.PostInfo
}

PostInfoEntry holds data for formatting a single post's metadata/context.

type RoleEntry

type RoleEntry struct {
	Role *model.Role
}

RoleEntry holds data for formatting a single role.

type ScheduledPostEntry

type ScheduledPostEntry struct {
	HeaderLabel   string // e.g. "Scheduled Post 1"; empty to omit
	ScheduledPost *model.ScheduledPost
	ChannelName   string // resolved channel display name, optional
}

ScheduledPostEntry holds data for formatting a single scheduled post.

type SidebarCategoryEntry

type SidebarCategoryEntry struct {
	HeaderLabel string
	Category    *model.SidebarCategoryWithChannels
}

SidebarCategoryEntry holds data for formatting a single sidebar category.

type StatusEntry

type StatusEntry struct {
	HeaderLabel string
	Status      *model.Status
	Username    string // resolved, optional
}

StatusEntry holds data for formatting a single user's presence status.

type TeamEntry

type TeamEntry struct {
	Team        *model.Team // the source team
	MemberCount int64       // -1 means don't show
}

TeamEntry holds data for formatting a single team.

type TeamMemberEntry

type TeamMemberEntry struct {
	HeaderLabel string
	Member      *model.TeamMember
	Username    string // resolved, optional
}

TeamMemberEntry holds data for formatting a single team membership record.

type ThreadSummaryEntry

type ThreadSummaryEntry struct {
	HeaderLabel string
	Thread      *model.ThreadResponse
	Username    string // root post author
}

ThreadSummaryEntry holds data for formatting a single thread from the inbox.

type UserEntry

type UserEntry struct {
	HeaderLabel string      // e.g. "User 1"; empty for member lists
	User        *model.User // the source user
	Role        string      // "admin", "member", "guest", "" — from MemberRole
}

UserEntry holds data for formatting a single user.

Jump to

Keyboard shortcuts

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