Documentation
¶
Index ¶
- func ExtractTickets(text string, projectKeys []string) []string
- func LoadIndex() (*models.SlackIndex, error)
- func LoadToken() (*config.SlackToken, error)
- func ResolveChannel(idOrName string) string
- func ResolveChannelMentions(text string) string
- func ResolveGroupMentions(text string) string
- func ResolveMentions(text string) string
- func ResolveUser(idOrUsername string) string
- func SaveIndex(idx *models.SlackIndex) error
- func SaveMentionStatusCache(cache *MentionStatusCache) error
- func SaveToken(token *config.SlackToken) error
- type Client
- func (c *Client) ClassifyMentionStatus(channelID, timestamp string, myUserIDs, myBotIDs []string) MentionStatus
- func (c *Client) DeleteMessage(channelID, timestamp string) error
- func (c *Client) GetBotID() (string, error)
- func (c *Client) GetBotUserID() (string, error)
- func (c *Client) GetChannelInfo(channelID string) (*slack.Channel, error)
- func (c *Client) GetChannelMembers(channelID string) ([]string, error)
- func (c *Client) GetMentionsInChannels(userID string, channels []string, limit int, since int64) ([]Mention, error)
- func (c *Client) GetReactions(channelID, timestamp string) ([]slack.ItemReaction, error)
- func (c *Client) GetThreadReplies(channelID, threadTS string) ([]slack.Message, error)
- func (c *Client) GetUserPresence(userID string) (*slack.UserPresence, error)
- func (c *Client) HasUserToken() bool
- func (c *Client) IndexAll(...) (*models.SlackIndex, error)
- func (c *Client) ListChannels() ([]slack.Channel, error)
- func (c *Client) ListUserGroups() ([]slack.UserGroup, error)
- func (c *Client) ListUsers() ([]slack.User, error)
- func (c *Client) OpenConversation(userID string) (string, error)
- func (c *Client) PostMessage(channelID, text string) (string, error)
- func (c *Client) PostMessageWithBlocks(channelID, fallbackText string, blocks []slack.Block) (string, error)
- func (c *Client) ReplyToThread(channelID, threadTS, text string) (string, error)
- func (c *Client) Search(query string, count int, since int64) ([]SearchResult, int, error)
- func (c *Client) SearchMentions(userID string, limit int, since int64) ([]Mention, int, error)
- func (c *Client) SearchMessages(query string, count int) ([]slack.SearchMessage, int, error)
- func (c *Client) SetUserPresence(presence string) error
- func (c *Client) TestAuth() (*slack.AuthTestResponse, error)
- func (c *Client) TestUserAuth() (*slack.AuthTestResponse, error)
- func (c *Client) UpdateMessage(channelID, timestamp, text string) (string, error)
- type Mention
- type MentionStatus
- type MentionStatusCache
- type OAuthFlow
- type ProgressFunc
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTickets ¶
ExtractTickets extracts ticket references from text given a list of project keys. For example, with projectKeys=["DEV", "TEL"], it will find "DEV-123", "TEL-456", etc.
func LoadIndex ¶
func LoadIndex() (*models.SlackIndex, error)
LoadIndex loads the Slack index from disk
func LoadToken ¶
func LoadToken() (*config.SlackToken, error)
LoadToken loads the Slack token from the config file
func ResolveChannel ¶
ResolveChannel resolves a channel name or ID to a channel ID
func ResolveChannelMentions ¶ added in v0.42.0
ResolveChannelMentions converts #channel mentions in text to Slack <#CHANNEL_ID> format Example: "Check #dev-team for updates" -> "Check <#C0123456789> for updates"
func ResolveGroupMentions ¶ added in v0.45.0
ResolveGroupMentions converts @group-handle mentions in text to Slack <!subteam^GROUP_ID> format Example: "Hey @sre-team check this" -> "Hey <!subteam^S0123456789> check this" Run after ResolveMentions so individual users take precedence over groups
func ResolveMentions ¶
ResolveMentions converts @username mentions in text to Slack <@USER_ID> format Example: "Hey @john.doe check this" -> "Hey <@U0123456789> check this"
func ResolveUser ¶
ResolveUser resolves a username or ID to a user ID
func SaveIndex ¶
func SaveIndex(idx *models.SlackIndex) error
SaveIndex saves the Slack index to disk
func SaveMentionStatusCache ¶ added in v0.4.0
func SaveMentionStatusCache(cache *MentionStatusCache) error
SaveMentionStatusCache saves the cache to disk
func SaveToken ¶
func SaveToken(token *config.SlackToken) error
SaveToken saves the Slack token to the config file
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Slack API client
func NewClientWithAppToken ¶
NewClientWithAppToken creates a client that can also use Socket Mode
func NewClientWithUserToken ¶
NewClientWithUserToken creates a client with both bot and user tokens The user token enables search API access
func (*Client) ClassifyMentionStatus ¶
func (c *Client) ClassifyMentionStatus(channelID, timestamp string, myUserIDs, myBotIDs []string) MentionStatus
ClassifyMentionStatus determines the status of a mention based on reactions and replies myUserIDs should include user IDs (U...) for the bot and authenticated user myBotIDs should include bot IDs (B...) to check against message BotID field
func (*Client) DeleteMessage ¶ added in v0.46.0
DeleteMessage deletes an existing message
func (*Client) GetBotUserID ¶
GetBotUserID returns the user ID of the authenticated bot
func (*Client) GetChannelInfo ¶
GetChannelInfo gets information about a channel
func (*Client) GetChannelMembers ¶ added in v0.43.0
GetChannelMembers returns all member user IDs for a channel, handling pagination and rate limits
func (*Client) GetMentionsInChannels ¶
func (c *Client) GetMentionsInChannels(userID string, channels []string, limit int, since int64) ([]Mention, error)
GetMentionsInChannels scans channel history for mentions of a user (works with bot tokens) If since is non-zero, only returns mentions from after that time
func (*Client) GetReactions ¶
func (c *Client) GetReactions(channelID, timestamp string) ([]slack.ItemReaction, error)
GetReactions returns reactions on a message Uses user token if available (for channels bot isn't a member of), falls back to bot token
func (*Client) GetThreadReplies ¶
GetThreadReplies returns replies in a thread Uses user token if available (for channels bot isn't a member of), falls back to bot token
func (*Client) GetUserPresence ¶
func (c *Client) GetUserPresence(userID string) (*slack.UserPresence, error)
GetUserPresence gets the presence status of a user (requires user token)
func (*Client) HasUserToken ¶
HasUserToken returns true if a user token is configured for search
func (*Client) IndexAll ¶
func (c *Client) IndexAll(channelProgressFn, userProgressFn, groupProgressFn, memberProgressFn ProgressFunc) (*models.SlackIndex, error)
IndexAll fetches all channels, users, user groups and builds the index
func (*Client) ListChannels ¶
ListChannels lists channels the bot is a member of
func (*Client) ListUserGroups ¶ added in v0.45.0
ListUserGroups lists all user groups in the workspace
func (*Client) OpenConversation ¶
OpenConversation opens a DM conversation with a user and returns the channel ID
func (*Client) PostMessage ¶
PostMessage sends a message to a channel
func (*Client) PostMessageWithBlocks ¶
func (c *Client) PostMessageWithBlocks(channelID, fallbackText string, blocks []slack.Block) (string, error)
PostMessageWithBlocks sends a message with Block Kit blocks
func (*Client) ReplyToThread ¶
ReplyToThread sends a reply to a thread
func (*Client) SearchMentions ¶
SearchMentions searches for mentions of a user using the search API Returns mentions sorted by timestamp descending. Requires user token.
func (*Client) SearchMessages ¶
SearchMessages searches for messages matching a query (requires user token with search:read scope)
func (*Client) SetUserPresence ¶
SetUserPresence sets the user's presence status (requires user token) presence must be "auto" or "away"
func (*Client) TestAuth ¶
func (c *Client) TestAuth() (*slack.AuthTestResponse, error)
TestAuth tests the authentication and returns bot info
func (*Client) TestUserAuth ¶
func (c *Client) TestUserAuth() (*slack.AuthTestResponse, error)
TestUserAuth tests the user token authentication and returns user info
type Mention ¶
type Mention struct {
ChannelID string
ChannelName string
UserID string
Username string
Timestamp string
ThreadTS string // Parent thread timestamp (if this is a reply)
Text string
Permalink string
Status MentionStatus
}
Mention represents a message that mentions a user
type MentionStatus ¶
type MentionStatus string
MentionStatus indicates whether a mention has been handled
const ( MentionStatusPending MentionStatus = "Pending" // No reaction or reply MentionStatusAcked MentionStatus = "Acked" // Has reaction but no reply MentionStatusReplied MentionStatus = "Replied" // Has reply from bot or user )
type MentionStatusCache ¶ added in v0.4.0
type MentionStatusCache struct {
// Key format: "channelID:timestamp" -> status
Statuses map[string]MentionStatus `json:"statuses"`
}
MentionStatusCache caches classification results for mentions Only "Replied" and "Acked" statuses are cached (they're stable) "Pending" is not cached as it may change when user replies
func LoadMentionStatusCache ¶ added in v0.4.0
func LoadMentionStatusCache() (*MentionStatusCache, error)
LoadMentionStatusCache loads the cache from disk
func (*MentionStatusCache) Get ¶ added in v0.4.0
func (c *MentionStatusCache) Get(channelID, timestamp string) MentionStatus
Get returns the cached status for a mention, or empty string if not cached
func (*MentionStatusCache) Set ¶ added in v0.4.0
func (c *MentionStatusCache) Set(channelID, timestamp string, status MentionStatus)
Set caches a status (only Replied and Acked are cached)
type OAuthFlow ¶
type OAuthFlow struct {
// contains filtered or unexported fields
}
OAuthFlow handles Slack OAuth authentication
func NewOAuthFlow ¶
NewOAuthFlow creates a new OAuth flow handler
func (*OAuthFlow) ExchangeCode ¶
ExchangeCode exchanges an authorization code for tokens
func (*OAuthFlow) GetAuthURL ¶
GetAuthURL returns the URL to start the OAuth flow
func (*OAuthFlow) StartAuthServer ¶
StartAuthServer starts a local HTTPS server to handle the OAuth callback
type ProgressFunc ¶
type ProgressFunc func(completed, total int)
ProgressFunc is called during indexing with progress updates