Documentation ¶
Overview ¶
Package slack provides a simple client to send messages to Slack channels.
Index ¶
Constants ¶
const SLACK_POST_MESSAGE_API = "https://slack.com/api/chat.postMessage"
SLACK_POST_MESSAGE_API is the endpoint provides by Slack's web api to send messages.
const SLACK_TOKEN = "SLACK_TOKEN"
SLACK_TOKEN is used to obtain an auth token from environment or if available by assigned secrets mananger.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to send messages to Slack using it's web api.
func New ¶
func New() *Client
New will return a client to send messages to Slack. Auth token will be taken from environment using SLACK_TOKEN. For other token sources use secrets manager with NewFromConfig.
func NewFromConfig ¶
func NewFromConfig(conf config.Config, secretsManager secrets.SecretsManager) *Client
NewFromConfig returns a client to send messages to Slack. You can pass a config to set a default channel and secrets managet to obtain auth token. Both are optional.
func (*Client) Send ¶
Send will send passed message to previous assigned channel. Passed message is send as section block in plain text. Header is optional and will be send as a header block if passed.
func (*Client) SendToChannel ¶
SendToChannel will send passed message to given channel. Message is send as section block in plain text. Header is optional and will be send as a header block if passed.
func (*Client) WithChannel ¶
WithChannel assign passed channel id to client. Usefull if most messages should be send to one channel.