36 lines
693 B
Go
36 lines
693 B
Go
package model
|
|
|
|
import (
|
|
"io/ioutil"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type Config struct {
|
|
BirthdayFile string `yaml:"birthday_file"`
|
|
TelegramNotifications *TelegramNotificationsConfig `yaml:"telegram_notifications"`
|
|
}
|
|
|
|
type TelegramNotificationsConfig struct {
|
|
BotToken string `yaml:"bot_token"`
|
|
ChannelID string `yaml:"channel_id"`
|
|
}
|
|
|
|
// ToDo: to be implemented
|
|
func (c *Config) IsValid() error {
|
|
return nil
|
|
}
|
|
|
|
func ReadConfig(path string) (*Config, error) {
|
|
fileBytes, err := ioutil.ReadFile(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var config *Config
|
|
if err := yaml.Unmarshal(fileBytes, &config); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return config, nil
|
|
}
|