notification

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 9 Imported by: 0

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.

func GetClient

func GetClient(notification config.Notification) (Client, error)

GetClient returns a client of the specified type. Each available type is defined as a constant.

type DiscordClient

type DiscordClient struct {
	Session *discordgo.Session
	// contains filtered or unexported fields
}

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.

func (*DiscordClient) Stop

func (dc *DiscordClient) Stop() error

Stop closes 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

type SlackClient struct {
	Client *slackApi.Client
	// contains filtered or unexported fields
}

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

type TelegramClient struct {
	Bot *tele.Bot
	// contains filtered or unexported fields
}

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.

func (*TelegramClient) Stop

func (tc *TelegramClient) Stop() error

Stop stops the Telegram bot.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL