ntfy

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoConfig = fmt.Errorf("no notify config")

Functions

func Notify

func Notify(ctx context.Context, text string) (err error)

func R

func R() *resty.Request

Types

type Config

type Config struct {
	Timeout time.Duration `json:"ntfy.timeout" yaml:"ntfy.timeout"`
	Proxy   string        `json:"ntfy.proxy"   yaml:"ntfy.proxy"`
	Retry   int           `json:"ntfy.retry"   yaml:"ntfy.retry"`

	DingtalkConfig `yaml:",squash"`
	TelegramConfig `yaml:",squash"`
	WebhookConfig  `yaml:",squash"`
}

func C

func C() Config

type DingtalkConfig

type DingtalkConfig struct {
	Token  *string `json:"ntfy.dingtalk.token"  yaml:"ntfy.dingtalk.token"`
	Secret string  `json:"ntfy.dingtalk.secret" yaml:"ntfy.dingtalk.secret"`
}

func (DingtalkConfig) Name

func (DingtalkConfig) Name() string

func (DingtalkConfig) Notify

func (c DingtalkConfig) Notify(_ context.Context, text string) error

func (DingtalkConfig) Sign

func (c DingtalkConfig) Sign() (string, string)

type Interface

type Interface interface {
	Name() string
	Notify(ctx context.Context, text string) error
}

type TelegramConfig

type TelegramConfig struct {
	Token  *string `json:"ntfy.telegram.token"   yaml:"ntfy.telegram.token"`
	ChatId string  `json:"ntfy.telegram.chat_id" yaml:"ntfy.telegram.chat_id"`
}

func (TelegramConfig) Name

func (TelegramConfig) Name() string

func (TelegramConfig) Notify

func (c TelegramConfig) Notify(_ context.Context, text string) error

type WebhookConfig

type WebhookConfig struct {
	URL *string `json:"ntfy.webhook.url" yaml:"ntfy.webhook.url"`
	// optional: GET or POST, default is GET
	Method string `json:"ntfy.webhook.method" yaml:"ntfy.webhook.method"`
	// only available when method is POST
	// optional: JSON or FORM, default is FORM
	//  - FORM is request by `application/x-www-form-urlencoded`
	//  - JSON is request by `application/json`
	Type string `json:"ntfy.webhook.type" yaml:"ntfy.webhook.type"`
	// the key of text in request body or query string
	// default is text
	Key string `json:"ntfy.webhook.key" yaml:"ntfy.webhook.key"`
	// extra values
	Extra map[string]string `json:"ntfy.webhook.extra" yaml:"ntfy.webhook.extra"`
	// headers
	Header map[string]string `json:"ntfy.webhook.headers" yaml:"ntfy.webhook.headers"`
}

WebhookConfig is the config for webhook.

ServerChan

ntfy:
  webhook:
    url: https://sctapi.ftqq.com/key.send
    method: post
    type: json
    key: desp
    extras:
    title: test

func (WebhookConfig) Name

func (c WebhookConfig) Name() string

func (WebhookConfig) Notify

func (c WebhookConfig) Notify(_ context.Context, text string) error

Jump to

Keyboard shortcuts

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