birthdaybot/server/server.go

28 lines
508 B
Go
Raw Normal View History

2023-06-29 22:46:17 +01:00
package server
import (
2023-06-30 09:33:25 +01:00
"fmt"
"git.ctrlz.es/mgdelacroix/birthdaybot/model"
2023-06-30 09:33:25 +01:00
"git.ctrlz.es/mgdelacroix/birthdaybot/parser"
)
2023-06-30 09:33:25 +01:00
type Server struct {
config *model.Config
birthdays []*model.Birthday
}
func New(config *model.Config) (*Server, error) {
2023-06-30 09:33:25 +01:00
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
2023-06-29 22:46:17 +01:00
}