telegram

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrComm will be used when the communication to telegram fails.
	ErrComm = errors.New("error communicating with telegram")
)

Functions

func NewNotifier

func NewNotifier(cfg Config) (forward.Notifier, error)

NewNotifier returns a notifier is a Telegram notifier that knows how to send alerts to telegram.

Types

type Client

type Client interface {
	Send(c tgbotapi.Chattable) (tgbotapi.Message, error)
}

Client is an small abstraction for the telegram-bot-api client. the client of this lib should satisfy directly. More info here: https://godoc.org/github.com/go-telegram-bot-api/telegram-bot-api.

type Config

type Config struct {
	// This is the ID of the channel or group where the alerts
	// will be sent by default.
	// Got from here https://github.com/GabrielRF/telegram-id#web-channel-id
	// You ca get the the ID like this:
	// - Enter the telegram web app and there to the channel/group.
	// - Check the URL, it has this schema: https://web.telegram.org/#/im?p=c1234567891_12345678912345678912
	// - Get the `c1234567891_`, get this part: `1234567891`.
	// - Add `-100` (until you have 13 characters), this should be the chat ID: `-1001234567891`
	DefaultTelegramChatID int64
	// TemplateRenderer is the renderer that will be used to render the
	// notifications before sending to Telegram.
	TemplateRenderer notify.TemplateRenderer
	// Client is the telegram client is compatible with "github.com/go-telegram-bot-api/telegram-bot-api"
	// library client API.
	Client Client
	// Logger is the logger.
	Logger log.Logger
}

Config is the configuration of the Notifier.

Jump to

Keyboard shortcuts

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