Documentation
¶
Overview ¶
Package notify notifies out of band interactions via webhook
Index ¶
- Constants
- type Attachment
- type DiscordClient
- type DiscordMessage
- type Notify
- type Options
- type SimpleSlackRequest
- type SlackClient
- func (sc *SlackClient) SendError(message string, options ...string) (err error)
- func (sc *SlackClient) SendInfo(message string, options ...string) (err error)
- func (sc *SlackClient) SendJobNotification(job SlackJobNotification) error
- func (sc *SlackClient) SendSlackNotification(sr SimpleSlackRequest) error
- func (sc *SlackClient) SendWarning(message string, options ...string) (err error)
- type SlackJobNotification
- type SlackMessage
- type TelegramClient
- type TelegramResponse
Constants ¶
const ( DefaultTelegraTimeout = 5 * time.Second Endpoint = "https://api.telegram.org/bot{{apikey}}/sendMessage?chat_id={{chatid}}&text={{message}}" )
DefaultTelegraTimeout to conclude operations
const DefaultDiscordTimeout = 5 * time.Second
DefaultDiscordTimeout to conclude operations
const DefaultSlackTimeout = 5 * time.Second
DefaultSlackTimeout to conclude operations
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
Color string `json:"color,omitempty"`
Fallback string `json:"fallback,omitempty"`
CallbackID string `json:"callback_id,omitempty"`
ID int `json:"id,omitempty"`
AuthorID string `json:"author_id,omitempty"`
AuthorName string `json:"author_name,omitempty"`
AuthorSubname string `json:"author_subname,omitempty"`
AuthorLink string `json:"author_link,omitempty"`
AuthorIcon string `json:"author_icon,omitempty"`
Title string `json:"title,omitempty"`
TitleLink string `json:"title_link,omitempty"`
Pretext string `json:"pretext,omitempty"`
Text string `json:"text,omitempty"`
ImageURL string `json:"image_url,omitempty"`
ThumbURL string `json:"thumb_url,omitempty"`
// Fields and actions are not defined.
MarkdownIn []string `json:"mrkdwn_in,omitempty"`
TS json.Number `json:"ts,omitempty"`
}
Attachment of slack message
type DiscordClient ¶
type DiscordClient struct {
WebHookURL string
UserName string
Avatar string
TimeOut time.Duration
// contains filtered or unexported fields
}
DiscordClient handling webhooks
func (*DiscordClient) SendDiscordNotification ¶
func (dc *DiscordClient) SendDiscordNotification(discordMessage *DiscordMessage) error
SendDiscordNotification with json structure
func (*DiscordClient) SendInfo ¶
func (dc *DiscordClient) SendInfo(message string) (err error)
SendInfo to discord
type DiscordMessage ¶
type DiscordMessage struct {
Username string `json:"username,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
Content string `json:"content,omitempty"`
}
DiscordMessage json structure
type Notify ¶
type Notify struct {
// contains filtered or unexported fields
}
Notify handles the notification engine
func NewWithOptions ¶
NewWithOptions create a new instance of notify with options
func (*Notify) SendNotification ¶
SendNotification to registered webhooks
type Options ¶
type Options struct {
// Slack
SlackWebHookURL string
SlackUsername string
SlackChannel string
Slack bool
// Discord
DiscordWebHookURL string
DiscordWebHookUsername string
DiscordWebHookAvatarURL string
Discord bool
// Telegram
TelegramAPIKey string
TelegramChatID string
Telegram bool
}
Options of internal webhooks
type SimpleSlackRequest ¶
SimpleSlackRequest basic request
type SlackClient ¶
type SlackClient struct {
WebHookURL string
UserName string
Channel string
TimeOut time.Duration
// contains filtered or unexported fields
}
SlackClient holding the slack communication logic
func (*SlackClient) SendError ¶
func (sc *SlackClient) SendError(message string, options ...string) (err error)
SendError message
func (*SlackClient) SendInfo ¶
func (sc *SlackClient) SendInfo(message string, options ...string) (err error)
SendInfo message
func (*SlackClient) SendJobNotification ¶
func (sc *SlackClient) SendJobNotification(job SlackJobNotification) error
SendJobNotification will post a job notification to slack
func (*SlackClient) SendSlackNotification ¶
func (sc *SlackClient) SendSlackNotification(sr SimpleSlackRequest) error
SendSlackNotification will post to an 'Incoming Webook' url setup in Slack Apps. It accepts some text and the slack channel is saved within Slack.
func (*SlackClient) SendWarning ¶
func (sc *SlackClient) SendWarning(message string, options ...string) (err error)
SendWarning message
type SlackJobNotification ¶
SlackJobNotification structure
type SlackMessage ¶
type SlackMessage struct {
Username string `json:"username,omitempty"`
IconEmoji string `json:"icon_emoji,omitempty"`
Channel string `json:"channel,omitempty"`
Text string `json:"text,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
}
SlackMessage structure
type TelegramClient ¶ added in v0.0.2
TelegramClient handling webhooks
func (*TelegramClient) SendInfo ¶ added in v0.0.2
func (dc *TelegramClient) SendInfo(message string) (err error)
SendInfo to telegram
type TelegramResponse ¶ added in v0.0.2
type TelegramResponse struct {
Ok bool `json:"ok"`
ErrorCode int `json:"error_code,omitempty"`
Description string `json:"description,omitempty"`
}
TelegramResponse structure