Documentation
¶
Index ¶
- Constants
- type Attachment
- type Field
- type Manager
- func (m *Manager) Broadcast(ctx context.Context, message string) []error
- func (m *Manager) BroadcastAsync(ctx context.Context, message string) <-chan NotificationResult
- func (m *Manager) BroadcastAsyncWithOptions(ctx context.Context, msg *Message) <-chan NotificationResult
- func (m *Manager) BroadcastWithOptions(ctx context.Context, msg *Message) []error
- func (m *Manager) Get(name string) (Notifier, bool)
- func (m *Manager) List() []string
- func (m *Manager) Register(notifier Notifier) error
- func (m *Manager) Send(ctx context.Context, provider, message string) error
- func (m *Manager) SendWithOptions(ctx context.Context, provider string, msg *Message) error
- func (m *Manager) Unregister(name string)
- type Message
- type NotificationError
- type NotificationResult
- type Notifier
- type SlackConfig
- type SlackNotifier
- func (s *SlackNotifier) GetClient() *slack.Client
- func (s *SlackNotifier) Name() string
- func (s *SlackNotifier) Send(ctx context.Context, message string) error
- func (s *SlackNotifier) SendFile(ctx context.Context, channel, filePath, title, comment string) error
- func (s *SlackNotifier) SendRichMessage(ctx context.Context, channel string, blocks []slack.Block) error
- func (s *SlackNotifier) SendWithOptions(ctx context.Context, msg *Message) error
- type TelegramConfig
- type TelegramNotifier
Constants ¶
const ( PriorityHigh = "high" PriorityNormal = "normal" PriorityLow = "low" )
Priority constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
Attachment represents a message attachment
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple notification providers
func (*Manager) BroadcastAsync ¶
func (m *Manager) BroadcastAsync(ctx context.Context, message string) <-chan NotificationResult
BroadcastAsync sends a message to all registered notifiers asynchronously
func (*Manager) BroadcastAsyncWithOptions ¶
func (m *Manager) BroadcastAsyncWithOptions(ctx context.Context, msg *Message) <-chan NotificationResult
BroadcastAsyncWithOptions sends a message with options to all registered notifiers asynchronously
func (*Manager) BroadcastWithOptions ¶
BroadcastWithOptions sends a message with options to all registered notifiers
func (*Manager) SendWithOptions ¶
SendWithOptions sends a message with options to a specific notifier
func (*Manager) Unregister ¶
Unregister removes a notifier from the manager
type Message ¶
type Message struct {
// Text is the main message content
Text string
// Title is an optional title for the message
Title string
// Priority defines the message priority (high, normal, low)
Priority string
// Channel defines the target channel/chat (provider-specific)
Channel string
// Attachments for rich messages (provider-specific)
Attachments []Attachment
// Metadata for additional provider-specific data
Metadata map[string]interface{}
}
Message represents a notification message with options
type NotificationError ¶
NotificationError represents an error that occurred during notification
func (*NotificationError) Error ¶
func (e *NotificationError) Error() string
func (*NotificationError) Unwrap ¶
func (e *NotificationError) Unwrap() error
type NotificationResult ¶
NotificationResult represents the result of a notification attempt
type Notifier ¶
type Notifier interface {
// Send sends a simple text message
Send(ctx context.Context, message string) error
// SendWithOptions sends a message with additional options
SendWithOptions(ctx context.Context, msg *Message) error
// Name returns the name of the notification provider
Name() string
}
Notifier defines the interface that all notification providers must implement
type SlackConfig ¶
type SlackConfig struct {
// Token is the Slack Bot or User OAuth token
Token string
// DefaultChannel is the default channel to send messages to (e.g., #general or @username)
DefaultChannel string
// Username is the bot username (optional)
Username string
// IconEmoji is the bot icon emoji (optional, e.g., :robot_face:)
IconEmoji string
// WebhookURL for incoming webhooks (alternative to Token)
WebhookURL string
}
SlackConfig holds configuration for Slack notifications
type SlackNotifier ¶
type SlackNotifier struct {
// contains filtered or unexported fields
}
SlackNotifier sends notifications via Slack API
func NewSlackNotifier ¶
func NewSlackNotifier(config SlackConfig) (*SlackNotifier, error)
NewSlackNotifier creates a new Slack notifier
func (*SlackNotifier) GetClient ¶
func (s *SlackNotifier) GetClient() *slack.Client
GetClient returns the underlying Slack client for advanced usage
func (*SlackNotifier) Name ¶
func (s *SlackNotifier) Name() string
Name returns the name of the provider
func (*SlackNotifier) Send ¶
func (s *SlackNotifier) Send(ctx context.Context, message string) error
Send sends a simple text message
func (*SlackNotifier) SendFile ¶
func (s *SlackNotifier) SendFile(ctx context.Context, channel, filePath, title, comment string) error
SendFile uploads a file to Slack
func (*SlackNotifier) SendRichMessage ¶
func (s *SlackNotifier) SendRichMessage(ctx context.Context, channel string, blocks []slack.Block) error
SendRichMessage sends a message with blocks for rich formatting
func (*SlackNotifier) SendWithOptions ¶
func (s *SlackNotifier) SendWithOptions(ctx context.Context, msg *Message) error
SendWithOptions sends a message with additional options
type TelegramConfig ¶
type TelegramConfig struct {
// BotToken is the Telegram Bot API token
BotToken string
// ChatID is the default chat ID to send messages to
ChatID string
// ParseMode defines how to parse the message (Markdown, HTML, or empty for plain text)
ParseMode string
// HTTPClient allows custom HTTP client (optional)
HTTPClient *http.Client
}
TelegramConfig holds configuration for Telegram notifications
type TelegramNotifier ¶
type TelegramNotifier struct {
// contains filtered or unexported fields
}
TelegramNotifier sends notifications via Telegram Bot API
func NewTelegramNotifier ¶
func NewTelegramNotifier(config TelegramConfig) (*TelegramNotifier, error)
NewTelegramNotifier creates a new Telegram notifier
func (*TelegramNotifier) Name ¶
func (t *TelegramNotifier) Name() string
Name returns the name of the provider
func (*TelegramNotifier) Send ¶
func (t *TelegramNotifier) Send(ctx context.Context, message string) error
Send sends a simple text message
func (*TelegramNotifier) SendPhoto ¶
func (t *TelegramNotifier) SendPhoto(ctx context.Context, chatID, photoURL, caption string) error
SendPhoto sends a photo with caption
func (*TelegramNotifier) SendWithOptions ¶
func (t *TelegramNotifier) SendWithOptions(ctx context.Context, msg *Message) error
SendWithOptions sends a message with additional options