diff --git a/README.md b/README.md index fc20963..6a6e65c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ information of the subject so you can reach them easily. - [ ] Create the bot scaffold - [X] Define how to read the birthdays info +- [ ] Add a logger instance to the config +- [ ] Add config validation on server creation - [ ] Create a configurable template to fill with each notification - [ ] Create different message systems to use with the bot - [ ] Enjoy! diff --git a/server/server.go b/server/server.go index f7f3ca1..bf8efa5 100644 --- a/server/server.go +++ b/server/server.go @@ -1,11 +1,27 @@ package server import ( + "fmt" + "git.ctrlz.es/mgdelacroix/birthdaybot/model" + "git.ctrlz.es/mgdelacroix/birthdaybot/parser" ) -type Server struct{} +type Server struct { + config *model.Config + birthdays []*model.Birthday +} func New(config *model.Config) (*Server, error) { - return nil, nil + birthdays, err := parser.ParseCSV(config.BirthdayFile) + if err != nil { + return nil, fmt.Errorf("cannot parse CSV file %s: %w", config.BirthdayFile, err) + } + + server := &Server{ + config: config, + birthdays: birthdays, + } + + return server, nil }