noti

package module
v0.0.0-...-4cfaff0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: MIT Imports: 5 Imported by: 0

README

Noti

Simply send notification to IM. Slack, Teams, Wechat Work, etc...

  • Wechat Work
  • Slack
  • Teams

Getting start

Use Noti by Environment Variables

NOTI_PROVIDER=wework
WEWORK_INFO_KEY=
WEWORK_WARN_KEY=
WEWORK_ERROR_KEY=

The KEY can find in Wechat Work group robot url.

Then use noti just like this:

noti.Info("info")
noti.Warn("warn")
noti.Error("error")

Documentation

Index

Constants

View Source
const (
	ProviderWework = "wework"
)

All sender provider

Variables

This section is empty.

Functions

func Error

func Error(args ...interface{})

Error send default error notification

func ErrorMD

func ErrorMD(lines []string)

ErrorMD send default markdown error notification

func Errorf

func Errorf(format string, a ...interface{})

Errorf send default error notification with format

func Info

func Info(args ...interface{})

Info send default info notification

func InfoMD

func InfoMD(lines []string)

InfoMD send default markdown info notification

func Infof

func Infof(format string, a ...interface{})

Infof send default info notification with format

func SetDebug

func SetDebug()

SetDebug set default noti to debug mode

func Warn

func Warn(args ...interface{})

Warn send default warn notification

func WarnMD

func WarnMD(lines []string)

WarnMD send default markdown warn notification

func Warnf

func Warnf(format string, a ...interface{})

Warnf send default warn notification with format

Types

type MsgMarkdown

type MsgMarkdown struct {
	Content string `json:"content"`
}

MsgMarkdown is md message api model

type MsgText

type MsgText struct {
	Content string `json:"content"`
}

MsgText is text message api model

type Noti

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

Noti is noti instance

func NewNoti

func NewNoti(settings *Settings) *Noti

func (*Noti) Error

func (n *Noti) Error(args ...interface{})

func (*Noti) ErrorMD

func (n *Noti) ErrorMD(lines []string)

func (*Noti) Errorf

func (n *Noti) Errorf(format string, a ...interface{})

func (*Noti) Info

func (n *Noti) Info(args ...interface{})

func (*Noti) InfoMD

func (n *Noti) InfoMD(lines []string)

func (*Noti) Infof

func (n *Noti) Infof(format string, a ...interface{})

func (*Noti) SetDebug

func (n *Noti) SetDebug()

SetDebug force set debug mode

func (*Noti) SetLogger

func (n *Noti) SetLogger(logger *zap.SugaredLogger)

SetLogger accept a custom zap sugared logger

func (*Noti) Warn

func (n *Noti) Warn(args ...interface{})

func (*Noti) WarnMD

func (n *Noti) WarnMD(lines []string)

func (*Noti) Warnf

func (n *Noti) Warnf(format string, a ...interface{})

type RobotMsg

type RobotMsg struct {
	MsgType  string       `json:"msgtype"`
	Text     *MsgText     `json:"text,omitempty"`
	MarkDown *MsgMarkdown `json:"markdown,omitempty"`
}

RobotMsg is message api model

type Sender

type Sender interface {
	Info(args ...interface{}) error
	Warn(args ...interface{}) error
	Error(args ...interface{}) error
	InfoMD(lines []string) error
	WarnMD(lines []string) error
	ErrorMD(lines []string) error
}

Sender interface

type Settings

type Settings struct {
	NotiProvider string `default:"debug"`
	Wework       WeworkSender
}

Settings will be defined in New func or from Env

type WeworkSender

type WeworkSender struct {
	BaseURL  string `default:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key="`
	InfoKey  string
	WarnKey  string
	ErrorKey string
}

WeworkSender can send notification to wechat work.

func (WeworkSender) Error

func (s WeworkSender) Error(args ...interface{}) error

Error 程序出错通知

func (WeworkSender) ErrorMD

func (s WeworkSender) ErrorMD(lines []string) error

ErrorMD 出错通知 Markdown

func (WeworkSender) Info

func (s WeworkSender) Info(args ...interface{}) error

Info 一般通知

func (WeworkSender) InfoMD

func (s WeworkSender) InfoMD(lines []string) error

InfoMD 一般通知 Markdown

func (WeworkSender) Ready

func (s WeworkSender) Ready() bool

Ready check if wechat work sender ready

func (WeworkSender) SendRobotMarkdown

func (s WeworkSender) SendRobotMarkdown(key string, lines []string) error

SendRobotMarkdown 向机器人发送 Markdown 通知

func (WeworkSender) SendRobotMsg

func (s WeworkSender) SendRobotMsg(key, tp, content string) error

SendRobotMsg send robot message by wechat work web api

func (WeworkSender) Warn

func (s WeworkSender) Warn(args ...interface{}) error

Warn 紧急通知

func (WeworkSender) WarnMD

func (s WeworkSender) WarnMD(lines []string) error

WarnMD 紧急通知 Markdown

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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