slack

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type Kit

type Kit struct {
	// contains filtered or unexported fields
}

func NewKit

func NewKit(token string, config RetryConfig) Kit

func (*Kit) GetAllChannels

func (s *Kit) GetAllChannels(ctx context.Context) ([]slack.Channel, error)

https://api.slack.com/docs/conversations-api https://api.slack.com/methods/conversations.list

Required scopes:

  • channels:read (public channels)
  • groups:read (private channels)

func (*Kit) GetFullCommandRequest

func (s *Kit) GetFullCommandRequest(ctx context.Context, body string) (SlashCommandRequest, error)

GetFullCommandRequest to retrieve correct channel name for "private group"s. Before March 2021, a private channel was "private group" in Slack implementation. And slash command payloads which Slack sends to us, contains wrong channel name info for private groups. So we need retrieve the correct channel name via Slack API. https://api.slack.com/types/group

func (Kit) PostMessage

func (s Kit) PostMessage(ctx context.Context, channelID string, channelName string, payload map[string]interface{}) (PostMessageResult, error)

https://api.slack.com/methods/chat.postMessage

type OriginalSlashCommandRequest

type OriginalSlashCommandRequest struct {
	Command             string
	ChannelID           string
	OriginalChannelName string
	Text                string
}

type PostMessageResult added in v1.0.8

type PostMessageResult struct {
	Type PostMessageResultType
	// Only when Type is ServerFailure
	StatusCode int
	Body       string
	// Only when Type is DomainFailure
	Reason      string
	ChannelID   string
	ChannelName string
}

Pack all neccessary fields into one struct to work-around no enum.

type PostMessageResultType added in v1.0.8

type PostMessageResultType int
const (
	PostMessageResultOK PostMessageResultType = iota
	PostMessageResultServerTimeoutFailure
	PostMessageResultServerFailure
	PostMessageResultDomainFailure
)

type RetryConfig added in v1.0.7

type RetryConfig struct {
	Max     int
	WaitMin time.Duration
	WaitMax time.Duration
	// Includes TCP connection establishment, TLS handshake, send HTTP request, read response body.
	ReadTimeout time.Duration
}

type SlashCommandRequest

type SlashCommandRequest struct {
	OriginalSlashCommandRequest
	ChannelName string
	Supported   bool
}

Jump to

Keyboard shortcuts

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