Documentation ¶
Overview ¶
Package slackposter posts a payload to Slack incoming webhook.
See README.md for more info.
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"` AuthorLink string `json:"author_link"` AuthorName string `json:"author_name"` Color string `json:"color"` Fallback string `json:"fallback"` Fields []Field `json:"fields"` ImageURL string `json:"image_url"` MrkdwnIn []string `json:"mrkdwn_in"` Pretext string `json:"pretext"` Text string `json:"text"` ThumbURL string `json:"thumb_url"` TitleLink string `json:"title_link"` Title string `json:"title"` Ts int64 `json:"ts"` }
Attachment represents a `attachment`.
type Config ¶
type Config struct { Channel string `json:"channel"` IconEmoji string `json:"icon_emoji"` Username string `json:"username"` WebhookURL string `json:"webhook_url"` }
Config is the configuration of SlackPoster.
type Field ¶
type Field struct { Short bool `json:"short"` Title string `json:"title"` Value string `json:"value"` }
Field represents a `field`.
type Payload ¶
type Payload struct { Attachments []Attachment `json:"attachments"` Channel string `json:"channel"` IconEmoji string `json:"icon_emoji"` LinkNames bool `json:"link_names"` Mrkdwn bool `json:"mrkdwn"` Text string `json:"text"` Username string `json:"username"` }
Payload is represented a Slack messsage format.
Refer to: Attaching content and links to messages | Slack https://api.slack.com/docs/message-attachments
func (*Payload) AppendField ¶
AppendField append a Field to Attachments.
type SlackPoster ¶
type SlackPoster struct { Channel string DryRun bool IconEmoji string Username string WebhookURL string }
SlackPoster represents a poster for Slack incoming webhook. SlackPoster must be created by calling NewSlackPoster().
func NewSlackPoster ¶
func NewSlackPoster(c Config) SlackPoster
NewSlackPoster create a new SlackPoster given a Config.
func (SlackPoster) NewPayload ¶
func (sp SlackPoster) NewPayload() Payload
NewPayload create a new Payload.
func (SlackPoster) PostMessage ¶
func (sp SlackPoster) PostMessage(message string) error
PostMessage posts a message to WebhookURL.
func (SlackPoster) PostPayload ¶
func (sp SlackPoster) PostPayload(payload Payload) error
PostPayload posts a payload to WebhookURL.