notify

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package notify 提供官方通知 helper 内部的渠道注册表。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Has

func Has(name string) bool

Has 判断通知渠道是否已注册(含别名)。

func Register

func Register(n Notifier)

Register 注册内置通知渠道。重复的 ID 或别名会直接 panic。

func ResetForTest

func ResetForTest()

ResetForTest 清空注册表,仅供测试使用。

func Send

func Send(channel string, cfg map[string]any, msg Message) error

Send 按渠道 ID 发送一条通知。

Types

type Definition

type Definition struct {
	ID          string   `json:"id"`
	Name        string   `json:"name,omitempty"`
	Description string   `json:"description,omitempty"`
	Aliases     []string `json:"aliases,omitempty"`
	Fields      []Field  `json:"fields,omitempty"`
}

Definition 描述一个通知渠道及其配置字段。

type DuplicateError

type DuplicateError struct{ ID string }

DuplicateError 表示通知渠道 ID 或别名冲突。

func (*DuplicateError) Error

func (e *DuplicateError) Error() string

type Field

type Field = protocol.NotifyField

Field 描述通知渠道的配置字段,与协议结构保持一致。

type Message

type Message struct {
	Title string
	Body  string
}

Message 是一次通知内容。Title 与 Body 均为纯文本。

type Notifier

type Notifier interface {
	// Definition 返回渠道元数据与配置字段。
	Definition() Definition
	// Notify 发送一条通知。
	Notify(cfg map[string]any, msg Message) error
}

Notifier 是通知渠道的统一接口。

func List

func List() []Notifier

List 返回按 ID 排序的全部通知渠道。

func Lookup

func Lookup(name string) (Notifier, bool)

Lookup 按 ID 或别名查找通知渠道。

type Option

type Option = protocol.NotifyOption

Option 是下拉选项。

Directories

Path Synopsis
providers
channels
Package channels 提供官方通知 helper 内置的渠道实现。
Package channels 提供官方通知 helper 内置的渠道实现。

Jump to

Keyboard shortcuts

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