Documentation
¶
Index ¶
- Variables
- func GetBitbucketClient(cfg config.Bitbucket) (*bitbucket.DefaultApiService, error)
- func GetChannelIDAndName(identifier string) (id string, name string)
- func GetContextBlock(text string) *slack.ContextBlock
- func GetHTTPClient() *http.Client
- func GetInteractionButton(id, text, command string, args ...slack.Style) *slack.ButtonBlockElement
- func GetSlackArchiveLink(message msg.Ref) string
- func GetSlackLink(name string, url string, args ...string) slack.AttachmentAction
- func GetTextBlock(text string) *slack.SectionBlock
- func GetUserIDAndName(identifier string) (id string, name string)
- func HandleMessage(message msg.Message)
- func HandleMessageWithDoneHandler(message msg.Message) *sync.WaitGroup
- type Slack
- func (s *Slack) AddReaction(reaction util.Reaction, ref msg.Ref)
- func (s *Slack) GetThreadMessages(ref msg.Ref) ([]slack.Message, error)
- func (s *Slack) GetUserPresence(user string) (*slack.UserPresence, error)
- func (s *Slack) PinMessage(channel string, timestamp string) error
- func (s *Slack) RemoveReaction(reaction util.Reaction, ref msg.Ref)
- func (s *Slack) ReplyError(ref msg.Ref, err error)
- func (s *Slack) SendBlockMessage(ref msg.Ref, blocks []slack.Block, options ...slack.MsgOption) string
- func (s *Slack) SendBlockMessageToUser(user string, blocks []slack.Block, options ...slack.MsgOption) string
- func (s *Slack) SendEphemeralMessage(ref msg.Ref, text string, options ...slack.MsgOption)
- func (s *Slack) SendMessage(ref msg.Ref, text string, options ...slack.MsgOption) string
- func (s *Slack) SendToUser(user string, text string)
- func (s *Slack) UploadFile(params slack.UploadFileV2Parameters) (*slack.FileSummary, error)
- type SlackClient
Constants ¶
This section is empty.
Variables ¶
var AllChannels map[string]string
AllChannels is a map of each channelsId and the name
var AllUsers config.UserMap
AllUsers is a lookup from user-id to user-name
var AuthResponse slack.AuthTestResponse
AuthResponse is holding some basic Slack metadata for the current connection, like Bot-Id, Workspace etc
var InternalMessages = make(chan msg.Message, 50)
InternalMessages is internal queue of internal messages @deprecated -> use HandleMessageWithDoneHandler instead
Functions ¶
func GetBitbucketClient ¶
func GetBitbucketClient(cfg config.Bitbucket) (*bitbucket.DefaultApiService, error)
GetBitbucketClient initialized a API client based on the given config
func GetChannelIDAndName ¶
GetChannelIDAndName returns channel-id and channel-name by an identifier which can be an id or a name
func GetContextBlock ¶
func GetContextBlock(text string) *slack.ContextBlock
GetContextBlock generates a "Context block" https://api.slack.com/reference/block-kit/blocks#context
func GetHTTPClient ¶
GetHTTPClient returns the http client for this bot to use the default go-client with a Timeout of 10s
func GetInteractionButton ¶
func GetInteractionButton(id, text, command string, args ...slack.Style) *slack.ButtonBlockElement
GetInteractionButton generates a block "Button" which is able to execute the given command once https://api.slack.com/reference/block-kit/blocks#actions
func GetSlackArchiveLink ¶
GetSlackArchiveLink returns a permalink to the ref which can be shared
func GetSlackLink ¶
func GetSlackLink(name string, url string, args ...string) slack.AttachmentAction
GetSlackLink generates a "link button" as a slack.AttachmentAction which will open the given URL in the Slack client (when pressed)
func GetTextBlock ¶
func GetTextBlock(text string) *slack.SectionBlock
GetTextBlock wraps a simple text in a Slack Block Section
func GetUserIDAndName ¶
GetUserIDAndName returns the user-id and user-name based on a identifier. If can get a user-id or name
func HandleMessage ¶
HandleMessage will register the given message in the queue...and returns a sync.WaitGroup which can be used to see when the message is handled
Types ¶
type Slack ¶
type Slack struct { *slack.Client Socket *socketmode.Client // contains filtered or unexported fields }
Slack is wrapper to the slack.Client which also holds the the socketmode.Client and all needed config
func GetSlackClient ¶
GetSlackClient establishes a connection to the slack server.
func (*Slack) AddReaction ¶
AddReaction will add a reaction from the given message
func (*Slack) GetThreadMessages ¶ added in v2.2.10
GetThreadMessages will send Slack Blocks/Sections to the target
func (*Slack) GetUserPresence ¶ added in v2.2.10
func (s *Slack) GetUserPresence(user string) (*slack.UserPresence, error)
GetUserPresence returns the current presence of a user, using the "users.getPresence" API
func (*Slack) PinMessage ¶ added in v2.3.9
PinMessage will pin a message to the channel
func (*Slack) RemoveReaction ¶
RemoveReaction will remove a reaction from the given message
func (*Slack) ReplyError ¶
ReplyError send a error message as a reply to the user and log it in the log + send it to ErrorChannel (if defined)
func (*Slack) SendBlockMessage ¶
func (s *Slack) SendBlockMessage(ref msg.Ref, blocks []slack.Block, options ...slack.MsgOption) string
SendBlockMessage will send Slack Blocks/Sections to the target
func (*Slack) SendBlockMessageToUser ¶ added in v2.2.10
func (s *Slack) SendBlockMessageToUser(user string, blocks []slack.Block, options ...slack.MsgOption) string
SendBlockMessageToUser will send Slack Blocks/Sections to the target
func (*Slack) SendEphemeralMessage ¶ added in v2.2.2
SendEphemeralMessage sends a message just visible to the current user see https://api.slack.com/methods/chat.postEphemeral
func (*Slack) SendMessage ¶
SendMessage is the "slow" reply via POST request, needed for Attachment or MsgRef
func (*Slack) SendToUser ¶
SendToUser sends a message to any user via IM channel
func (*Slack) UploadFile ¶ added in v2.2.10
func (s *Slack) UploadFile(params slack.UploadFileV2Parameters) (*slack.FileSummary, error)
UploadFile uploads a file to Slack
type SlackClient ¶
type SlackClient interface { // ReplyError Replies a error to the current channel/user/thread + log it! ReplyError(ref msg.Ref, err error) // SendMessage is the extended version of Reply and accepts any slack.MsgOption SendMessage(ref msg.Ref, text string, options ...slack.MsgOption) string // SendEphemeralMessage sends a message just visible to the current user SendEphemeralMessage(ref msg.Ref, text string, options ...slack.MsgOption) SendBlockMessageToUser(user string, blocks []slack.Block, options ...slack.MsgOption) string // SendBlockMessage will send Slack Blocks/Sections to the target SendBlockMessage(ref msg.Ref, blocks []slack.Block, options ...slack.MsgOption) string // SendToUser sends a simple text message to a user, using "@username or @U12334" SendToUser(user string, text string) RemoveReaction(reaction util.Reaction, ref msg.Ref) AddReaction(reaction util.Reaction, ref msg.Ref) GetReactions(item slack.ItemRef, params slack.GetReactionsParameters) ([]slack.ItemReaction, error) // GetConversationHistory loads the message history from slack GetConversationHistory(*slack.GetConversationHistoryParameters) (*slack.GetConversationHistoryResponse, error) // GetThreadMessages loads message from a given thread GetThreadMessages(ref msg.Ref) ([]slack.Message, error) // GetUserPresence returns the current presence of a user, using the "users.getPresence" API GetUserPresence(user string) (*slack.UserPresence, error) // UploadFile uploads a file to Slack UploadFile(params slack.UploadFileV2Parameters) (*slack.FileSummary, error) // PinMessage will pin a message to the channel PinMessage(channel string, timestamp string) error }
SlackClient is the main interface which is used for all commands to interact with slack for tests we have a mock for it, for production use, we use a slack.Client with some custom logic