wecom

package
v0.0.0-...-adfb252 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: AGPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultChannelType = "groupRobot"
View Source
const DefaultToUser = "@all"
View Source
const DefaultsgType = "markdown"
View Source
const FullValidConfigForTesting = `` /* 253-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 = `{
	"url": "test-url-secret"
}`

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

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Channel     string  `json:"-" yaml:"-"`
	EndpointURL string  `json:"endpointUrl,omitempty" yaml:"endpointUrl,omitempty"`
	URL         string  `json:"url" yaml:"url"`
	AgentID     string  `json:"agent_id,omitempty" yaml:"agent_id,omitempty"`
	CorpID      string  `json:"corp_id,omitempty" yaml:"corp_id,omitempty"`
	Secret      string  `json:"secret,omitempty" yaml:"secret,omitempty"`
	MsgType     MsgType `json:"msgtype,omitempty" yaml:"msgtype,omitempty"`
	Message     string  `json:"message,omitempty" yaml:"message,omitempty"`
	Title       string  `json:"title,omitempty" yaml:"title,omitempty"`
	ToUser      string  `json:"touser,omitempty" yaml:"touser,omitempty"`
}

func NewConfig

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

type MsgType

type MsgType string
const MsgTypeMarkdown MsgType = "markdown" // use these in available_receivers.go too
const MsgTypeText MsgType = "text"

func (MsgType) IsValid

func (mt MsgType) IsValid() bool

IsValid checks wecom message type

type Notifier

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

Notifier is responsible for sending alert notifications to WeCom.

func New

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

func (*Notifier) GetAccessToken

func (w *Notifier) GetAccessToken(ctx context.Context) (string, error)

GetAccessToken returns the access token for apiapp

func (*Notifier) Notify

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

Notify send an alert notification to WeCom.

func (*Notifier) SendResolved

func (w *Notifier) SendResolved() bool

Jump to

Keyboard shortcuts

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