Documentation
¶
Overview ¶
Package slack provides methods to send notifications to Slack channels via webhooks.
Index ¶
- Variables
- func Init(configs ...Config) error
- func Reset()
- type Builder
- type Config
- type Message
- type MessageOptions
- type Service
- func (s *Service) Send(message string, opts *MessageOptions) (string, error)
- func (s *Service) SendAlert(message string) (string, error)
- func (s *Service) SendAlertWithOptions(message string, opts *MessageOptions) (string, error)
- func (s *Service) SendInfo(message string) (string, error)
- func (s *Service) SendInfoWithOptions(message string, opts *MessageOptions) (string, error)
- func (s *Service) SendWarning(message string) (string, error)
- func (s *Service) SendWarningWithOptions(message string, opts *MessageOptions) (string, error)
- func (s *Service) SetDefaultChannel(channel string) *Service
- func (s *Service) SetDefaultIcon(iconEmoji string) *Service
- func (s *Service) SetDefaultIconURL(iconURL string) *Service
- func (s *Service) SetDefaultUsername(username string) *Service
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidConfig = errors.New("invalid configuration")
)
Standard errors for the package
Functions ¶
Types ¶
type Builder ¶ added in v0.1.0
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a way to create Slack service instances with custom prefixes
func WithPrefix ¶ added in v0.1.0
WithPrefix creates a new Builder with the specified prefix
type Config ¶
type Config struct {
WebhookURL string `env:"SLACK_WEBHOOK_URL"`
Channel string `env:"SLACK_CHANNEL"`
Username string `env:"SLACK_USERNAME,default:Beaver"`
IconEmoji string `env:"SLACK_ICON_EMOJI"`
IconURL string `env:"SLACK_ICON_URL"`
Timeout time.Duration `env:"SLACK_TIMEOUT,default:10s"`
}
Config defines slack configuration
type Message ¶
type Message struct {
Text string `json:"text"`
Channel string `json:"channel,omitempty"`
Username string `json:"username,omitempty"`
IconEmoji string `json:"icon_emoji,omitempty"`
IconURL string `json:"icon_url,omitempty"`
}
Message represents a Slack message to be sent
type MessageOptions ¶
MessageOptions contains optional parameters for Slack messages
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service represents a Slack notification service
func (*Service) Send ¶
func (s *Service) Send(message string, opts *MessageOptions) (string, error)
Send sends a raw message to Slack
func (*Service) SendAlertWithOptions ¶
func (s *Service) SendAlertWithOptions(message string, opts *MessageOptions) (string, error)
SendAlertWithOptions sends an alert message to Slack with custom options
func (*Service) SendInfoWithOptions ¶
func (s *Service) SendInfoWithOptions(message string, opts *MessageOptions) (string, error)
SendInfoWithOptions sends an informational message to Slack with custom options
func (*Service) SendWarning ¶
SendWarning sends a warning message to Slack
func (*Service) SendWarningWithOptions ¶
func (s *Service) SendWarningWithOptions(message string, opts *MessageOptions) (string, error)
SendWarningWithOptions sends a warning message to Slack with custom options
func (*Service) SetDefaultChannel ¶
SetDefaultChannel sets the default channel for all messages sent by this service
func (*Service) SetDefaultIcon ¶
SetDefaultIcon sets the default icon emoji for all messages sent by this service
func (*Service) SetDefaultIconURL ¶
SetDefaultIconURL sets the default icon URL for all messages sent by this service
func (*Service) SetDefaultUsername ¶
SetDefaultUsername sets the default username for all messages sent by this service