Notify Add Lark

This commit is contained in:
g1335333249
2024-10-17 12:39:18 +08:00
parent a035ba192a
commit 004c6a8506
11 changed files with 497 additions and 333 deletions

View File

@@ -3,6 +3,7 @@ package notify
import (
"context"
"fmt"
"github.com/nikoksr/notify/service/lark"
"strconv"
notifyPackage "github.com/nikoksr/notify"
@@ -17,6 +18,7 @@ const (
notifyChannelDingtalk = "dingtalk"
notifyChannelWebhook = "webhook"
notifyChannelTelegram = "telegram"
notifyChannelLark = "lark"
)
func Send(title, content string) error {
@@ -67,6 +69,8 @@ func getNotifiers() ([]notifyPackage.Notifier, error) {
notifiers = append(notifiers, temp)
case notifyChannelDingtalk:
notifiers = append(notifiers, getDingTalkNotifier(v))
case notifyChannelLark:
notifiers = append(notifiers, getLarkNotifier(v))
case notifyChannelWebhook:
notifiers = append(notifiers, getWebhookNotifier(v))
}
@@ -108,6 +112,10 @@ func getDingTalkNotifier(conf map[string]any) notifyPackage.Notifier {
})
}
func getLarkNotifier(conf map[string]any) notifyPackage.Notifier {
return lark.NewWebhookService(getString(conf, "webhookUrl"))
}
func getString(conf map[string]any, key string) string {
if _, ok := conf[key]; !ok {
return ""