digital-ocean-volume-snapshots/cmd/DigitalOceanSnapshotter/slackContext.go
2021-02-04 00:25:10 +01:00

22 lines
705 B
Go

package main
import "github.com/slack-go/slack"
// SlackContext is an helper struct to acess slack actions
type SlackContext struct {
client *slack.Client
channelID string
}
// SendMessageWithContent sends a message with content to the pre defined channel
func (s SlackContext) SendMessageWithContent(content string) error {
_, _, _, err := s.client.SendMessage(s.channelID, slack.MsgOptionText(content, true))
return err
}
// SendMessageWithEmbed sends a message with a Rich Embed to the pre defined channel
func (s SlackContext) SendMessageWithEmbed(attachment slack.Attachment) error {
_, _, _, err := s.client.SendMessage(s.channelID, slack.MsgOptionAttachments(attachment))
return err
}