This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
summer-utils/notifier/notifier.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
}