notify

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 13 Imported by: 0

README

Notifier

用于给用户发送邮件,短信等等

发送 Email
// 注册一个EmailNotifier 
// 参数依次为:smtp服务器地址,发送账户,发送账户密码
email, err = notifier.NewEmailNotifier("smtp.exmail.qq.com:25", "service@laily.me", "123")
// 参数为:接收方账户,发送邮件的主题和内容,内容支持html形式
email.SendMail("aa@laily.me;bb@laily.me","title","content")
发送 Alertover

Alertover 是一个实现了手机推送的 app,可以将需要推送的内容发送至 alertover 的服务器,然后推送至手机。source 和 receiver 的需要去 www.alertover.com 获取

	source := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	receiver := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	alert := notifier.NewAlertover(s)
	alert.SendAlert(receiver, "title", "content")

Documentation

Overview

通知发送 目前支持邮件和 alertover

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init added in v0.0.2

func Init()

func MDMsg

func MDMsg(title string, contents []string) []byte

MDSend a msg with title and multiple line content.

Types

type Alertover

type Alertover struct {
	// contains filtered or unexported fields
}

Alertover contain a source Alertover website: https://www.alertover.com/

func NewAlertover

func NewAlertover(source string) *Alertover

NewAlertover create a Alertover instance

func (*Alertover) SendAlert

func (self *Alertover) SendAlert(receiver, title, content string) string

SendAlert to send notification param are receiver alertover id, and message title and content

type EmailNotifier

type EmailNotifier struct {
	// contains filtered or unexported fields
}

EmailNotifier has param SMTPHost, SMTP account

func NewEmailNotifier

func NewEmailNotifier(host, from, password string) (*EmailNotifier, error)

NewEmailNotifier create a EmailNotifier instance host 邮箱 stmp 地址 from 邮箱地址 password 邮箱密码

func (*EmailNotifier) SendMail

func (m *EmailNotifier) SendMail(receiver string, title string, body string) error

SendMail to send notification to others, Params are receiver emails, separate with ";"; email subject and content; content can be html text

type ErrorHook

type ErrorHook struct {
	// contains filtered or unexported fields
}

func NewHook

func NewHook(projectName string, webhookURL string) (*ErrorHook, error)

NewHook

func NewHookByENV

func NewHookByENV() (*ErrorHook, error)

func (*ErrorHook) Fire

func (h *ErrorHook) Fire(e *logrus.Entry) error

func (*ErrorHook) Levels

func (h *ErrorHook) Levels() []logrus.Level

type LarkWebhook

type LarkWebhook struct {
	// contains filtered or unexported fields
}

func (*LarkWebhook) MDSend

func (l *LarkWebhook) MDSend(title string, contents []string) error

type Receiver

type Receiver struct {
	ID   string // receiver ident
	Type ReceiverType
}

Receiver represent a lark message receiver

func ChatReceiver

func ChatReceiver(chatID string) *Receiver

ChatReceiver create a receiver from a chat id.

func EmailReceiver

func EmailReceiver(email string) *Receiver

EmailReceiver create a receiver from email.

type ReceiverType

type ReceiverType string

ReceiverType ...

var (
	ReceiverEmail  ReceiverType = "email"
	ReceiverChatID ReceiverType = "chatID"
	ReceiverUserID ReceiverType = "userID"
	ReceiverOpenID ReceiverType = "openID"
)

Jump to

Keyboard shortcuts

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