Skip to content

cloud-org/msgpush

Repository files navigation

Table of Contents generated with DocToc

msgpush

通用推送消息 simple sdk

usage

go get -v github.com/cloud-org/msgpush
type NotifyPush struct {
	Notifys []msgpush.NotifyPush
}

func GetNotify(software, token string) (msgpush.NotifyPush, error) {
	switch software {
	case "dingtalk": // 钉钉推送
		return msgpush.NewDingTalk(token), nil
	case "wecom": // 企业微信推送
		return msgpush.NewWeCom(token), nil
	case "slack": // slack 推送
		return msgpush.NewSlack(token), nil
	case "pushdeer":
		return msgpush.NewPushDeer(token), nil
	case "feishu":
		return msgpush.NewFeiShu(token), nil
	default:
		return nil, fmt.Errorf("暂时不支持类型 %v", software)
	}
}

func (n *NotifyPush) Push(content string) {
	if n == nil {
		logx.Infof("notify push not init")
		return
	}
	for i := 0; i < len(n.Notifys); i++ {
		if err := n.Notifys[i].Send(content); err != nil {
			logx.Infof("notify err: %v", err)
			continue
		}
	}
}

acknowledgement

  • github.com/imroc/req