bot

package
v0.0.0-...-a5dde3d Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2019 License: EUPL-1.2 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlertColors = map[string]string{
	"alert":       "black",
	"information": "blue",
	"warning":     "orange",
	"critical":    "red",
	"resolved":    "green",
	"silenced":    "gray",
}

AlertColors represent the colors corresponding to the alert status

View Source
var AlertIcons = map[string]string{
	"alert":       "🔔️",
	"information": "ℹ️",
	"warning":     "⚠️",
	"critical":    "🚨",
	"resolved":    "✅",
	"silenced":    "🔕",
}

AlertIcons represent the icons corresponding to the alert status

Functions

func CreateMessage

func CreateMessage(status, name, summary, id string) (plain, html string)

CreateMessage formats a message using the status, name and summary

func FormatAlerts

func FormatAlerts(alerts []*alertmanager.Alert, labels bool) (string, string)

FormatAlerts formats alerts as plain text and HTML

func FormatSilences

func FormatSilences(silences []*types.Silence, state string) string

FormatSilences formats silences as Markdown.

Types

type Client

type Client struct {
	Matrix       *matrix.Client
	Alertmanager *alertmanager.Client
	// contains filtered or unexported fields
}

Client represents an Alertmanager/Matrix client

func NewClient

func NewClient(homeserver, userID, token, messageType, rooms, alertmanagerURL string) (client *Client, err error)

NewClient creates and starts a new Alertmanager/Matrix client

func (*Client) Alerts

func (c *Client) Alerts(silenced bool, labels bool) (string, string)

Alerts returns all or non-silenced alerts

func (*Client) DelSilence

func (c *Client) DelSilence(ids []string) string

DelSilence deletes silences

func (*Client) NewSilence

func (c *Client) NewSilence(author string, args []string) string

NewSilence creates a new silence and returns the ID

func (*Client) Run

func (c *Client) Run() error

Run the client in a blocking thread

func (*Client) Silences

func (c *Client) Silences(state string) string

Silences returns a Markdown formatted message containing silences with the specified state

Jump to

Keyboard shortcuts

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