slackkit

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Type BlockType `json:"type"`
	Text *Text     `json:"text,omitempty"`
}

Block is a single block of a notification.

func NewDivider added in v0.2.43

func NewDivider() Block

NewDivider creates a new divider block.

func NewHeader

func NewHeader(text string, emoji bool) Block

NewHeader creates a new header block.

func NewSection added in v0.2.43

func NewSection(text string, emoji bool) Block

NewSection creates a new section block.

type BlockType

type BlockType string

Block types are defined in the Slack API documentation.

const (
	Header  BlockType = "header"
	Divider BlockType = "divider"
	Section BlockType = "section"
)

Block types are defined in the Slack API documentation.

type Error added in v0.2.43

type Error string

Error is a custom error type for Slack notifications.

const (
	// ErrNilBlock is returned when a block is nil.
	ErrNilBlock Error = "nil block"

	// ErrNilText is returned when a text is nil.
	ErrNilText Error = "nil text"

	// ErrInvalidBlockType is returned when a block type is invalid.
	ErrInvalidBlockType Error = "invalid block type"

	// ErrInvalidBlockTextType is returned when a block text type is invalid.
	ErrInvalidBlockTextType Error = "invalid block text type"

	// ErrInvalidBlockTextStyle is returned when a block text style is invalid.
	ErrInvalidBlockTextStyle Error = "invalid block text style"

	// ErrInvalidBlockTextEmoji is returned when a block text emoji is invalid.
	ErrInvalidBlockTextEmoji Error = "invalid block text emoji"
)

Slack notification errors.

func (Error) Error added in v0.2.43

func (e Error) Error() string

type Notification

type Notification struct {
	Blocks []Block `json:"blocks"`
}

Notification is the main struct for sending notifications to Slack.

func NewNotification

func NewNotification(blocks ...Block) (*Notification, error)

NewNotification creates a new notification.

type Style

type Style struct {
	Bold   *bool `json:"bold,omitempty"`
	Italic *bool `json:"italic,omitempty"`
	Strike *bool `json:"strike,omitempty"`
}

Style is a style block of a notification.

type Text

type Text struct {
	Type  TextType `json:"type"`
	Text  string   `json:"text"`
	Emoji *bool    `json:"emoji,omitempty"`
	Style *Style   `json:"style,omitempty"`
}

Text is a single text block of a notification.

type TextType

type TextType string

Text types are defined in the Slack API documentation.

const (
	// PlainText is the default text type.
	PlainText TextType = "plain_text"

	// Markdown is the markdown text type.
	Markdown TextType = "mrkdwn"
)

Jump to

Keyboard shortcuts

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