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(text string, command string, args ...slack.Style) *slack.ButtonBlockElement
- func GetJiraClient(cfg *config.Jira) (*jira.Client, error)
- 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) CanHandleInteractions() bool
- 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) 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)
- type SlackClient
Constants ¶
This section is empty.
Variables ¶
var AuthResponse slack.AuthTestResponse
AuthResponse is holding some basic Slack metadata for the current connection, like Bot-Id, Workspace etc
var Channels map[string]string
Channels is a map of each channelsId and the name
var InternalMessages = make(chan msg.Message, 50)
InternalMessages is internal queue of internal messages @deprecated -> use HandleMessageWithDoneHandler instead
var Users config.UserMap
Users is a lookup from user-id to user-name
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(text string, 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 GetJiraClient ¶
GetJiraClient creates a jira client based on github.com/andygrunwald/go-jira and passes authentication credentials
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 RTM *slack.RTM Socket *socketmode.Client // contains filtered or unexported fields }
Slack is wrapper to the slack.Client which also holds the RTM connection OR the socketmode.Client and all needed config
func GetSlackClient ¶
GetSlackClient establishes a connection to the slack server. Either via "Socket Mode" or the legacy "RTM" connection
func (*Slack) AddReaction ¶
AddReaction will add a reaction from the given message
func (*Slack) CanHandleInteractions ¶
CanHandleInteractions checks if we have a slack connections which can inform us about events/interactions, like pressed buttons?
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) 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
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) // 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) // CanHandleInteractions checks if we have a slack connections which can inform us about events/interactions, like pressed buttons? CanHandleInteractions() bool }
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