v1

package
v0.0.0-release-12.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

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

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

View Source
const Version = schema.V1

Variables

View Source
var Schema = schema.IntegrationSchemaVersion{
	Version:   Version,
	CanCreate: true,
	Options: []schema.Field{
		{
			Label:        "Webhook URL",
			Description:  "Required if using GroupRobot",
			Element:      schema.ElementTypeInput,
			InputType:    schema.InputTypeText,
			Placeholder:  "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx",
			PropertyName: "url",
			Secure:       true,
			Required:     true,
			DependsOn:    "secret",
			Protected:    true,
		},
		{
			Label:        "Agent ID",
			Description:  "Required if using APIAPP, see https://work.weixin.qq.com/wework_admin/frame#apps create ApiApp",
			Element:      schema.ElementTypeInput,
			InputType:    schema.InputTypeText,
			Placeholder:  "1000002",
			PropertyName: "agent_id",
			Required:     true,
			DependsOn:    "url",
		},
		{
			Label:        "Corp ID",
			Description:  "Required if using APIAPP, see https://work.weixin.qq.com/wework_admin/frame#profile",
			Element:      schema.ElementTypeInput,
			InputType:    schema.InputTypeText,
			Placeholder:  "wwxxxxxxxxx",
			PropertyName: "corp_id",
			Required:     true,
			DependsOn:    "url",
		},
		{
			Label:        "Secret",
			Description:  "Required if using APIAPP",
			Element:      schema.ElementTypeInput,
			InputType:    schema.InputTypePassword,
			Placeholder:  "secret",
			PropertyName: "secret",
			Secure:       true,
			Required:     true,
			DependsOn:    "url",
		},
		{
			Label:        "Message Type",
			Element:      schema.ElementTypeSelect,
			PropertyName: "msgtype",
			SelectOptions: []schema.SelectOption{
				{
					Value: "text",
					Label: "Text",
				},
				{
					Value: "markdown",
					Label: "Markdown",
				},
			},
			Placeholder: "Text",
		},
		{
			Label:        "Message",
			Description:  "Custom WeCom message. You can use template variables.",
			Element:      schema.ElementTypeTextArea,
			Placeholder:  templates.DefaultMessageEmbed,
			PropertyName: "message",
		},
		{
			Label:        "Title",
			Element:      schema.ElementTypeTextArea,
			InputType:    schema.InputTypeText,
			Description:  "Templated title of the message",
			PropertyName: "title",
			Placeholder:  templates.DefaultMessageTitleEmbed,
		},
		{
			Label:        "To User",
			Element:      schema.ElementTypeInput,
			InputType:    schema.InputTypeText,
			Placeholder:  "@all",
			PropertyName: "touser",
		},
	},
}

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 log.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
⌂ 换网址