telegram

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTelegramParseMode = "HTML"
View Source
const FullValidConfigForTesting = `` /* 196-byte string literal not displayed */

FullValidConfigForTesting is a string representation of a JSON object that contains all fields supported by the notifier Config. It can be used without secrets.

View Source
const FullValidSecretsForTesting = `{
	"bottoken": "test-secret-token"
}`

FullValidSecretsForTesting is a string representation of JSON object that contains all fields that can be overridden from secrets

Variables

View Source
var (
	// APIURL of where the notification payload is sent. It is public to be overridable in integration tests.
	APIURL = "https://api.telegram.org/bot%s/%s"
)
View Source
var SupportedParseMode = map[string]string{"Markdown": "Markdown", "MarkdownV2": "MarkdownV2", DefaultTelegramParseMode: "HTML", "None": ""}

SupportedParseMode is a map of all supported values for field `parse_mode`. https://core.telegram.org/bots/api#formatting-options. Keys are options accepted by Grafana API, values are options accepted by Telegram API

Functions

This section is empty.

Types

type Config

type Config struct {
	BotToken              string `json:"bottoken,omitempty" yaml:"bottoken,omitempty"`
	ChatID                string `json:"chatid,omitempty" yaml:"chatid,omitempty"`
	Message               string `json:"message,omitempty" yaml:"message,omitempty"`
	ParseMode             string `json:"parse_mode,omitempty" yaml:"parse_mode,omitempty"`
	DisableWebPagePreview bool   `json:"disable_web_page_preview,omitempty" yaml:"disable_web_page_preview,omitempty"`
	ProtectContent        bool   `json:"protect_content,omitempty" yaml:"protect_content,omitempty"`
	DisableNotifications  bool   `json:"disable_notifications,omitempty" yaml:"disable_notifications,omitempty"`
}

func NewConfig

func NewConfig(jsonData json.RawMessage, decryptFn receivers.DecryptFunc) (Config, error)

type Notifier

type Notifier struct {
	*receivers.Base
	// contains filtered or unexported fields
}

Notifier is responsible for sending alert notifications to Telegram.

func New

func New(cfg Config, meta receivers.Metadata, template *templates.Template, sender receivers.WebhookSender, images images.Provider, logger logging.Logger) *Notifier

New is the constructor for the Telegram notifier

func (*Notifier) Notify

func (tn *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify send an alert notification to Telegram.

func (*Notifier) SendResolved

func (tn *Notifier) SendResolved() bool

Jump to

Keyboard shortcuts

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