slack

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package slack holds slack integration clients and message definitions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	AuthorIcon string   `json:"author_icon,omitempty"`
	AuthorLink string   `json:"author_link,omitempty"`
	AuthorName string   `json:"author_name,omitempty"`
	Color      string   `json:"color"`
	Fallback   string   `json:"fallback"`
	Fields     []*Field `json:"fields"`
	Footer     string   `json:"footer"`
	MarkdownIn []string `json:"mrkdwn_in"`
	ThumbURL   string   `json:"thumb_url"`
	Text       string   `json:"text,omitempty"`
	Timestamp  int64    `json:"ts"`
	Title      string   `json:"title"`
	TitleLink  string   `json:"title_link,omitempty"`
}

Attachment is a Slack message attachment, defined at: https://api.slack.com/docs/message-attachments

type Client

type Client struct {
	WebhookURL string
}

Client is capable of posting a message to a Slack webhook

func New

func New(webhookURL string) *Client

New creates a new Slack client

func (*Client) Post

func (c *Client) Post(ctx context.Context, payload *Payload) error

Post sends payload to a Slack channel

type Field

type Field struct {
	Short bool   `json:"short"`
	Title string `json:"title"`
	Value string `json:"value"`
}

Field is a single item within an attachment, defined at: https://api.slack.com/docs/message-attachments

type Payload

type Payload struct {
	Username    string        `json:"username,omitempty"`
	IconEmoji   string        `json:"icon_emoji,omitempty"`
	UnfurlLinks bool          `json:"unfurl_links,omitempty"`
	UnfurlMedia bool          `json:"unfurl_media,omitempty"`
	Text        string        `json:"text,omitempty"`
	Attachments []*Attachment `json:"attachments,omitempty"`
}

Payload is the wrapper for a Slack message, defined at: https://api.slack.com/docs/message-formatting

Jump to

Keyboard shortcuts

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