24 lines
521 B
Go
24 lines
521 B
Go
package notifier
|
|
|
|
import "errors"
|
|
|
|
var ErrInvalidNotifierType = errors.New("invalid notifier type")
|
|
|
|
type Notifier interface {
|
|
SendMessage(s string)
|
|
}
|
|
|
|
type Config struct {
|
|
Type string `yaml:"type"`
|
|
Token string `yaml:"token"` // the token used to log in to the bot
|
|
Target string `yaml:"target"` // the target chat or user to send updates to
|
|
}
|
|
|
|
func Init(conf Config) (Notifier, error) {
|
|
switch conf.Type {
|
|
case "telegram":
|
|
return newTelegram(conf.Token, conf.Target)
|
|
}
|
|
return nil, ErrInvalidNotifierType
|
|
}
|