-
Notifications
You must be signed in to change notification settings - Fork 61
/
shoutrrr.go
40 lines (32 loc) · 1.15 KB
/
shoutrrr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package shoutrrr
import (
"github.com/containrrr/shoutrrr/internal/meta"
"github.com/containrrr/shoutrrr/pkg/router"
"github.com/containrrr/shoutrrr/pkg/types"
)
var defaultRouter = router.ServiceRouter{}
// SetLogger sets the logger that the services will use to write progress logs
func SetLogger(logger types.StdLogger) {
defaultRouter.SetLogger(logger)
}
// Send notifications using a supplied url and message
func Send(rawURL string, message string) error {
service, err := defaultRouter.Locate(rawURL)
if err != nil {
return err
}
return service.Send(message, &types.Params{})
}
// CreateSender returns a notification sender configured according to the supplied URL
func CreateSender(rawURLs ...string) (*router.ServiceRouter, error) {
return router.New(nil, rawURLs...)
}
// NewSender returns a notification sender, writing any log output to logger and configured
// to send to the services indicated by the supplied URLs
func NewSender(logger types.StdLogger, serviceURLs ...string) (*router.ServiceRouter, error) {
return router.New(logger, serviceURLs...)
}
// Version returns the shoutrrr version
func Version() string {
return meta.Version
}