moved notifiers to seperate section in config

This commit is contained in:
BroodjeAap 2022-12-26 15:22:21 +00:00
parent 25cf91966e
commit 23bb6459ff

View file

@ -14,19 +14,19 @@ type TelegramNotifier struct {
}
func (telegram *TelegramNotifier) Open() bool {
bot, err := tgbotapi.NewBotAPI(viper.GetString("telegram.token"))
bot, err := tgbotapi.NewBotAPI(viper.GetString("notifiers.telegram.token"))
if err != nil {
log.Println("Could not start Telegram notifier:\n", err)
return false
}
telegram.Bot = bot
bot.Debug = viper.GetBool("telegram.debug")
bot.Debug = viper.GetBool("notifiers.telegram.debug")
log.Printf("Authorized telegram bot: %s", bot.Self.UserName)
return true
}
func (telegram *TelegramNotifier) Message(message string) bool {
msg := tgbotapi.NewMessage(viper.GetInt64("telegram.chat"), message)
msg := tgbotapi.NewMessage(viper.GetInt64("notifiers.telegram.chat"), message)
_, err := telegram.Bot.Send(msg)
if err != nil {
log.Println("Could not send Telegram message:\n", err)