{"modulePath":"github.com/codeGROOVE-dev/slacker","version":"v0.0.0-20260117180538-72f1ef61c586","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package slack\n\nPackage slack provides a Slack API client and interaction handlers.\n\n## Variables\n\n```go\nvar (\n\t// ErrNoDMToUpdate indicates no DM exists to update.\n\tErrNoDMToUpdate = errors.New(\"no DM found to update\")\n)\n```\nErrors.\n\n## Types\n\n```go\ntype API interface {\n\t// Team operations.\n\tGetTeamInfoContext(ctx context.Context) (*slack.TeamInfo, error)\n\tAuthTestContext(ctx context.Context) (*slack.AuthTestResponse, error)\n\n\t// Conversation operations.\n\tGetConversationInfoContext(ctx context.Context, input *slack.GetConversationInfoInput) (*slack.Channel, error)\n\tGetConversationHistoryContext(ctx context.Context, params *slack.GetConversationHistoryParameters) (*slack.GetConversationHistoryResponse, error)\n\tGetConversationsContext(ctx context.Context, params *slack.GetConversationsParameters) ([]slack.Channel, string, error)\n\tOpenConversationContext(ctx context.Context, params *slack.OpenConversationParameters) (*slack.Channel, bool, bool, error)\n\tGetUsersInConversationContext(ctx context.Context, params *slack.GetUsersInConversationParameters) ([]string, string, error)\n\n\t// Message operations.\n\tPostMessageContext(ctx context.Context, channelID string, options ...slack.MsgOption) (string, string, error)\n\tUpdateMessageContext(ctx context.Context, channelID, timestamp string, options ...slack.MsgOption) (string, string, string, error)\n\tSearchMessagesContext(ctx context.Context, query string, params slack.SearchParameters) (*slack.SearchMessages, error)\n\n\t// Reaction operations.\n\tAddReactionContext(ctx context.Context, name string, item slack.ItemRef) error\n\tRemoveReactionContext(ctx context.Context, name string, item slack.ItemRef) error\n\n\t// User operations.\n\tGetUserInfoContext(ctx context.Context, userID string) (*slack.User, error)\n\tGetUserPresenceContext(ctx context.Context, userID string) (*slack.UserPresence, error)\n\n\t// View operations.\n\tPublishViewContext(ctx context.Context, request slack.PublishViewContextRequest) (*slack.ViewResponse, error)\n}\n```\nAPI defines the interface for Slack API operations. This abstraction allows for easier testing by enabling mock implementations.\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient wraps the Slack API client with caching.\n\n```go\nfunc New(token, signingSecret string) *Client\n```\nNew creates a new Slack client with caching.\n\n```go\nfunc (c *Client) API() *slack.Client\n```\nAPI returns the underlying Slack API client for compatibility. This unwraps the API interface to return the raw \\*slack.Client. Only use this when integrating with code that hasn't been refactored to use the API interface yet.\n\n```go\nfunc (c *Client) BotInfo(ctx context.Context) (*slack.AuthTestResponse, error)\n```\nBotInfo returns information about the authenticated bot user (cached for 30 minutes).\n\n```go\nfunc (c *Client) ChannelHistory(\n\tctx context.Context, channelID string, oldest, latest string, limit int,\n) (*slack.GetConversationHistoryResponse, error)\n```\nChannelHistory retrieves channel message history with optional time filtering.\n\n```go\nfunc (c *Client) EventsHandler(writer http.ResponseWriter, r *http.Request)\n```\nEventsHandler handles Slack events.\n\n```go\nfunc (c *Client) FindDMMessagesInHistory(ctx context.Context, userID, prURL string, since time.Time) ([]DMLocation, error)\n```\nFindDMMessagesInHistory searches Slack DM history to find existing messages about a PR. This is the fallback when cache/datastore don't have the DM location. Searches since the given time in DM history using the Slack API directly.\n\n```go\nfunc (c *Client) HasRecentDMAboutPR(ctx context.Context, userID, prURL string) (bool, error)\n```\nHasRecentDMAboutPR checks if we recently sent a DM to this user about this PR (within last hour). This prevents duplicate DMs during rolling deployments.\n\n```go\nfunc (c *Client) InteractionsHandler(writer http.ResponseWriter, r *http.Request)\n```\nInteractionsHandler handles Slack interactive components.\n\n```go\nfunc (c *Client) InvalidateChannel(channelID string)\n```\nInvalidateChannel removes cached data for a specific channel (helpful during setup).\n\n```go\nfunc (c *Client) IsBotInChannel(ctx context.Context, channelID string) bool\n```\nIsBotInChannel checks if the bot is a member of the specified channel with adaptive caching.\n\n```go\nfunc (c *Client) IsUserActive(ctx context.Context, userID string) bool\n```\nIsUserActive checks if a user is currently active.\n\n```go\nfunc (c *Client) IsUserInChannel(ctx context.Context, channelID, userID string) bool\n```\nIsUserInChannel checks if a specific user is a member of the specified channel.\n\n```go\nfunc (c *Client) PostThread(ctx context.Context, channelID, text string, attachments []slack.Attachment) (string, error)\n```\nPostThread creates a new thread in a channel for a PR with retry logic.\n\n```go\nfunc (c *Client) PostThreadReply(ctx context.Context, channelID, threadTS, text string) error\n```\nPostThreadReply posts a reply to an existing thread with retry logic.\n\n```go\nfunc (c *Client) PublishHomeView(ctx context.Context, userID string, blocks []slack.Block) error\n```\nPublishHomeView publishes a view to a user's app home with retry logic.\n\n```go\nfunc (c *Client) ResolveChannelID(ctx context.Context, channelName string) string\n```\nResolveChannelID resolves a channel name (e.g., \"all-codegroove\" or \"#all-codegroove\") to a channel ID. Returns the channel ID if found, or the original input if it's already an ID or can't be resolved.\n\n```go\nfunc (c *Client) SaveDMMessageInfo(ctx context.Context, userID, prURL, channelID, messageTS, messageText string) error\n```\nSaveDMMessageInfo saves DM message info to state store for future updates.\n\n```go\nfunc (c *Client) SearchMessages(ctx context.Context, query string, params *slack.SearchParameters) (*slack.SearchMessages, error)\n```\nSearchMessages searches for messages using the Slack API.\n\n```go\nfunc (c *Client) SendDirectMessage(ctx context.Context, userID, text string) (dmChannelID, messageTS string, err error)\n```\nSendDirectMessage sends a direct message to a user with retry logic.\n\n```go\nfunc (c *Client) SendDirectMessageWithBlocks(ctx context.Context, userID string, blocks []slack.Block) (dmChannelID, messageTS string, err error)\n```\nSendDirectMessageWithBlocks sends a direct message to a user with Block Kit blocks.\n\n```go\nfunc (c *Client) SetHomeViewHandler(handler func(ctx context.Context, teamID, userID string) error)\n```\nSetHomeViewHandler registers a callback for app\\_home\\_opened events.\n\n```go\nfunc (c *Client) SetManager(manager *Manager)\n```\nSetManager sets the manager reference for cache invalidation.\n\n```go\nfunc (c *Client) SetReportHandler(handler func(ctx context.Context, teamID, userID string) error)\n```\nSetReportHandler registers a callback for /goose report slash command.\n\n```go\nfunc (c *Client) SetStateStore(store StateStore)\n```\nSetStateStore sets the state store for DM message tracking.\n\n```go\nfunc (c *Client) SetTeamID(teamID string)\n```\nSetTeamID sets the team ID for this client.\n\n```go\nfunc (c *Client) SlashCommandHandler(writer http.ResponseWriter, r *http.Request)\n```\nSlashCommandHandler handles Slack slash commands.\n\n```go\nfunc (c *Client) UpdateDMMessage(ctx context.Context, userID, prURL, newText string) error\n```\nUpdateDMMessage updates a previously sent DM message. Returns nil and logs debug if no DM exists, returns error if update fails.\n\n```go\nfunc (c *Client) UpdateMessage(ctx context.Context, channelID, timestamp, text string) error\n```\nUpdateMessage updates an existing message with retry logic.\n\n```go\nfunc (c *Client) UserInfo(ctx context.Context, userID string) (*slack.User, error)\n```\nUserInfo gets user information including timezone with retry logic.\n\n```go\nfunc (c *Client) UserPresence(ctx context.Context, userID string) (string, error)\n```\nUserPresence gets user presence (active/away) with retry logic.\n\n```go\nfunc (c *Client) UserTimezone(ctx context.Context, userID string) (string, error)\n```\nUserTimezone returns the IANA timezone string for a user (e.g., \"America/New\\_York\"). Uses caching to minimize API calls.\n\n```go\nfunc (c *Client) VerifySignature(signature, timestamp string, body []byte) bool\n```\nVerifySignature verifies a Slack request signature (exported for use by EventRouter).\n\n```go\nfunc (c *Client) WorkspaceInfo(ctx context.Context) (*slack.TeamInfo, error)\n```\nWorkspaceInfo returns information about the current workspace (cached for 1 hour).\n\n```go\ntype ConfigManager interface {\n\tConfig(org string) (*config.RepoConfig, bool)\n}\n```\nConfigManager defines the interface for configuration management. This interface allows for easier testing by enabling mock implementations.\n\n```go\ntype DMLocation struct {\n\tChannelID string\n\tMessageTS string\n}\n```\nDMLocation represents a DM message location in Slack.\n\n```go\ntype EventRouter struct {\n\t// contains filtered or unexported fields\n}\n```\nEventRouter routes Slack events to workspace-specific clients.\n\n```go\nfunc NewEventRouter(manager *Manager) *EventRouter\n```\nNewEventRouter creates a new event router.\n\n```go\nfunc (er *EventRouter) HandleEvents(w http.ResponseWriter, req *http.Request)\n```\nHandleEvents routes incoming Slack events to the appropriate workspace client.\n\n```go\nfunc (er *EventRouter) HandleInteractions(w http.ResponseWriter, req *http.Request)\n```\nHandleInteractions routes Slack interactions to the appropriate workspace client.\n\n```go\nfunc (er *EventRouter) HandleSlashCommand(w http.ResponseWriter, req *http.Request)\n```\nHandleSlashCommand routes slash commands to the appropriate workspace client.\n\n```go\ntype GitHubManager interface {\n\tAllOrgs() []string\n\tClientForOrg(org string) (*github.Client, bool)\n}\n```\nGitHubManager defines the interface for GitHub client management. This interface allows for easier testing by enabling mock implementations.\n\n```go\ntype HomeHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nHomeHandler handles app\\_home\\_opened events for a workspace.\n\n```go\nfunc NewHomeHandler(\n\tslackManager *Manager,\n\tgithubManager GitHubManager,\n\tconfigManager ConfigManager,\n\tstateStore state.Store,\n\treverseMapping UserMapper,\n) *HomeHandler\n```\nNewHomeHandler creates a new home view handler.\n\n```go\nfunc (h *HomeHandler) HandleAppHomeOpened(ctx context.Context, teamID, slackUserID string) error\n```\nHandleAppHomeOpened updates the app home view when a user opens it.\n\n```go\ntype Manager struct {\n\t// contains filtered or unexported fields\n}\n```\nManager manages Slack clients for multiple workspaces.\n\n```go\nfunc NewManager(signingSecret string) *Manager\n```\nNewManager creates a new Slack client manager.\n\n```go\nfunc (m *Manager) Client(ctx context.Context, teamID string) (*Client, error)\n```\nClient returns a Slack client for the given workspace. If the client doesn't exist in cache, it fetches the token from GSM.\n\n```go\nfunc (m *Manager) InvalidateCache(teamID string)\n```\nInvalidateCache removes a workspace from the cache, forcing a reload on next access.\n\n```go\nfunc (m *Manager) ListWorkspaces() []*WorkspaceMetadata\n```\nListWorkspaces returns metadata for all cached workspaces.\n\n```go\nfunc (m *Manager) RegisterWorkspace(ctx context.Context, teamID string, slackClient *slack.Client)\n```\nRegisterWorkspace registers a pre-configured Slack client for a workspace. This is only for integration testing - in production, clients are fetched from GSM.\n\n```go\nfunc (m *Manager) SetHomeViewHandler(handler func(ctx context.Context, teamID, userID string) error)\n```\nSetHomeViewHandler sets the home view handler on all current and future clients.\n\n```go\nfunc (m *Manager) SetReportHandler(handler func(ctx context.Context, teamID, userID string) error)\n```\nSetReportHandler sets the report handler on all current and future clients.\n\n```go\nfunc (m *Manager) SetStateStore(store StateStore)\n```\nSetStateStore sets the state store for DM message tracking.\n\n```go\nfunc (m *Manager) StoreWorkspace(ctx context.Context, metadata *WorkspaceMetadata, token string) error\n```\nStoreWorkspace stores a workspace's token and metadata in GSM.\n\n```go\ntype OAuthExchanger interface {\n\tExchangeCode(ctx context.Context, clientID, clientSecret, code string) (*slack.OAuthV2Response, error)\n}\n```\nOAuthExchanger exchanges OAuth authorization codes for access tokens.\n\n```go\ntype OAuthHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nOAuthHandler handles the OAuth callback from Slack.\n\n```go\nfunc NewOAuthHandler(manager *Manager, clientID, clientSecret string) *OAuthHandler\n```\nNewOAuthHandler creates a new OAuth handler. If manager is passed (implements WorkspaceStorer), it's used for both storage and debug listing.\n\n```go\nfunc (h *OAuthHandler) HandleCallback(writer http.ResponseWriter, req *http.Request)\n```\nHandleCallback handles the OAuth callback from Slack.\n\n```go\nfunc (h *OAuthHandler) HandleDebug(writer http.ResponseWriter, _ *http.Request)\n```\nHandleDebug returns JSON with installed workspaces (for debugging).\n\n```go\nfunc (h *OAuthHandler) HandleInstall(writer http.ResponseWriter, _ *http.Request)\n```\nHandleInstall serves the \"Add to Slack\" installation page.\n\n```go\ntype OAuthResponse struct {\n\tTeamID    string `json:\"team_id\"`\n\tTeamName  string `json:\"team_name\"`\n\tBotUserID string `json:\"bot_user_id\"`\n}\n```\nOAuthResponse is a simplified response for debugging.\n\n```go\ntype ReportHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nReportHandler handles manual daily report generation via slash command.\n\n```go\nfunc NewReportHandler(\n\tslackManager *Manager,\n\tgithubManager GitHubManager,\n\tstateStore state.Store,\n\treverseMapping UserMapper,\n) *ReportHandler\n```\nNewReportHandler creates a new report handler.\n\n```go\nfunc (h *ReportHandler) HandleReportCommand(ctx context.Context, teamID, slackUserID string) error\n```\nHandleReportCommand handles the /goose report slash command. It generates and sends a daily report for the requesting user, bypassing time window and interval checks.\n\n```go\ntype StateStore interface {\n\tDMMessage(ctx context.Context, userID, prURL string) (state.DMInfo, bool)\n\tSaveDMMessage(ctx context.Context, userID, prURL string, info state.DMInfo) error\n}\n```\nStateStore interface for DM message tracking.\n\n```go\ntype UserMapper interface {\n\tLookupGitHub(ctx context.Context, slackAPI usermapping.SlackAPI, slackUserID, org, emailDomain string) (*usermapping.ReverseMapping, error)\n\tSetOverrides(overrides map[string]string)\n}\n```\nUserMapper defines the interface for Slack-to-GitHub user mapping. This interface allows for easier testing by enabling mock implementations.\n\n```go\ntype WorkspaceMetadata struct {\n\tTeamID      string `json:\"team_id\"`\n\tTeamName    string `json:\"team_name\"`\n\tBotUserID   string `json:\"bot_user_id\"`\n\tAccessToken string `json:\"-\"` // Never serialize token to JSON\n}\n```\nWorkspaceMetadata contains metadata about a Slack workspace installation.\n\n```go\ntype WorkspaceStorer interface {\n\tStoreWorkspace(ctx context.Context, metadata *WorkspaceMetadata, token string) error\n}\n```\nWorkspaceStorer stores workspace credentials after OAuth completion.\n\n","path":"github.com/codeGROOVE-dev/slacker/pkg/slack","name":"slack","synopsis":"Package slack provides a Slack API client and interaction handlers.","isRedistributable":true}
