Documentation ¶
Overview ¶
Package notification implements interfaces to notification clients like Discord.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Start() error Stop() error AddStatusHandler(func() string) SendNotification(message string) error }
Client describes an interface that allows to send notification to a service.
type DiscordClient ¶
DiscordClient allows to interact with a Discord channel.
func NewDiscordClient ¶
func NewDiscordClient(token string, channelID string) (*DiscordClient, error)
NewDiscordClient starts and returns a new Discord client using the given token and channel.
func (*DiscordClient) AddStatusHandler ¶
func (dc *DiscordClient) AddStatusHandler(statusSummary func() string)
AddStatusHandler adds a handler to the bot that replies with the current monitoring status.
func (*DiscordClient) SendNotification ¶
func (dc *DiscordClient) SendNotification(message string) error
SendNotification sends the given message to the channel that is specified in the DiscordClient.
func (*DiscordClient) Start ¶
func (dc *DiscordClient) Start() error
Start opens the discord session.
type MockClient ¶ added in v0.2.1
type MockClient struct{}
MockClient provides a mock implementation of an notification provider for testing purpose.
func NewMockClient ¶ added in v0.2.1
func NewMockClient() *MockClient
NewMockClient returns a new mock client.
func (*MockClient) AddStatusHandler ¶ added in v0.2.1
func (mc *MockClient) AddStatusHandler(_ func() string)
AddStatusHandler mocks adding the status handler.
func (*MockClient) SendNotification ¶ added in v0.2.1
func (mc *MockClient) SendNotification(_ string) error
SendNotification mocks sending of notifications.
func (*MockClient) Start ¶ added in v0.2.1
func (mc *MockClient) Start() error
Start opens the mock session.
func (*MockClient) Stop ¶ added in v0.2.1
func (mc *MockClient) Stop() error
Stop closes the mock session.
type SlackClient ¶ added in v0.2.1
SlackClient allows to interact with a Discord channel.
func NewSlackClient ¶ added in v0.2.1
func NewSlackClient(botToken string, appToken string, channelID string) *SlackClient
NewSlackClient starts and returns a new Slack client using the given token and channel.
func (*SlackClient) AddStatusHandler ¶ added in v0.2.1
func (sc *SlackClient) AddStatusHandler(statusSummary func() string)
AddStatusHandler adds a handler to the bot that replies with the current monitoring status.
func (*SlackClient) SendNotification ¶ added in v0.2.1
func (sc *SlackClient) SendNotification(message string) error
SendNotification sends the given message to the channel that is specified in the SlackClient.
func (*SlackClient) Start ¶ added in v0.2.1
func (sc *SlackClient) Start() error
Start is not required for slack clients and thus always returns nil.
func (*SlackClient) Stop ¶ added in v0.2.1
func (sc *SlackClient) Stop() error
Stop closes the slack session.
type TelegramClient ¶
TelegramClient allows to interact with a Telegram channel.
func NewTelegramClient ¶
func NewTelegramClient(token string, userID string) (*TelegramClient, error)
NewTelegramClient starts and returns a new Telegram client using the given token.
func (*TelegramClient) AddStatusHandler ¶
func (tc *TelegramClient) AddStatusHandler(statusSummary func() string)
AddStatusHandler adds a handler to the bot that replies with the current monitoring status.
func (*TelegramClient) SendNotification ¶
func (tc *TelegramClient) SendNotification(message string) error
SendNotification sends the given message to the channel that is specified in the TelegramClient.
func (*TelegramClient) Start ¶
func (tc *TelegramClient) Start() error
Start starts the Telegram bot.