Skip to content

notifier is a Go library to send notification to other applications.

License

Notifications You must be signed in to change notification settings

moonD4rk/notifier

This branch is 1 commit ahead of, 1 commit behind main.

Folders and files

NameName
Last commit message
Last commit date
Feb 29, 2024
Apr 25, 2022
Apr 26, 2023
Feb 29, 2024
Feb 29, 2024
Feb 29, 2024
Feb 29, 2024
Apr 21, 2022
Apr 25, 2022
Apr 22, 2022
Feb 29, 2024
Apr 26, 2023
Apr 26, 2023
Apr 26, 2023
Apr 23, 2022

Repository files navigation

notifier

CI

notifier is a simple Go library to send notification to other applications.

Feature

Provider Code
DingTalk provider/dingtalk
Bark provider/bark
Lark provider/lark
Feishu provider/feishu
Server 酱 provider/serverchan

Install

go get -u github.com/moond4rk/notifier

Usage

package main

import (
	"os"

	"github.com/moond4rk/notifier"
)

func main() {
	var (
		dingtalkToken     = os.Getenv("dingtalk_token")
		dingtalkSecret    = os.Getenv("dingtalk_secret")
		barkKey           = os.Getenv("bark_key")
		barkServer        = notifier.DefaultBarkServer
		feishuToken       = os.Getenv("feishu_token")
		feishuSecret      = os.Getenv("feishu_secret")
		larkToken         = os.Getenv("lark_token")
		larkSecret        = os.Getenv("lark_secret")
		serverChanUserID  = "" // server chan's userID could be empty
		serverChanSendKey = os.Getenv("server_chan_send_key")
	)
	notifier := notifier.New(
		notifier.WithDingTalk(dingtalkToken, dingtalkSecret),
		notifier.WithBark(barkKey, barkServer),
		notifier.WithFeishu(feishuToken, feishuSecret),
		notifier.WithLark(larkToken, larkSecret),
		notifier.WithServerChan(serverChanUserID, serverChanSendKey),
	)

	var (
		subject = "this is subject"
		content = "this is content"
	)
	if err := notifier.Send(subject, content); err != nil {
		panic(err)
	}
}