2023-06-30 08:59:17 +01:00
|
|
|
[![pipeline status](https://gitlab.ctrlz.es/mgdelacroix/birthdaybot/badges/main/pipeline.svg)](https://gitlab.ctrlz.es/mgdelacroix/birthdaybot/-/commits/main)
|
|
|
|
|
2023-06-29 17:55:13 +01:00
|
|
|
# Birthday bot
|
|
|
|
|
|
|
|
A simple bot that notifies of birthdays, posting the contact
|
|
|
|
information of the subject so you can reach them easily.
|
|
|
|
|
2023-06-30 09:42:27 +01:00
|
|
|
## Configuration
|
|
|
|
|
|
|
|
There is an [example configuration file](./example-config.yml) that
|
2023-06-30 10:39:13 +01:00
|
|
|
can be used as a base to create your own configuration, and there is a
|
|
|
|
[birthdays example CSV file](./birthdays.csv) to load the data.
|
2023-06-30 09:42:27 +01:00
|
|
|
|
2023-07-10 20:25:54 +01:00
|
|
|
### Template file
|
2023-07-10 19:46:12 +01:00
|
|
|
|
|
|
|
The template can be configured using the `birthday_template` config
|
|
|
|
parameter to point to the template file. The template uses the Go
|
|
|
|
Template Format, and has the following properties available:
|
|
|
|
|
|
|
|
- `.Name`: the name of the person whose birthday we're notifying.
|
|
|
|
- `.Email`: the email of the person.
|
|
|
|
- `.Phone`: the phone of the person, as a string.
|
|
|
|
- `.YearOfBirth`: the year that the person was born, as number.
|
|
|
|
- `.MonthOfBirth`: the month that the person was born, as number.
|
|
|
|
- `.DayOfBirth`: the day that the person was born, as number.
|
|
|
|
|
2023-07-11 09:21:53 +01:00
|
|
|
There are as well some functions available to be used:
|
|
|
|
|
2023-07-11 10:30:29 +01:00
|
|
|
- `getYearsOld`: receives the year that a user was born, and returns
|
2023-07-11 09:21:53 +01:00
|
|
|
how old the user is getting.
|
|
|
|
|
2023-07-10 20:25:54 +01:00
|
|
|
### Pictures
|
|
|
|
|
|
|
|
Alongside the notification for each birthday, the bot can send a
|
|
|
|
picture for the person with the notification message. For this to
|
|
|
|
happen, you need to put the pictures in a folder, and point the
|
|
|
|
configuration to this folder using the property `birthdays.pictures`.
|
|
|
|
|
|
|
|
Each file should be named accordingly of the birthday it corresponds
|
|
|
|
to. The naming schema is `YEAR_MONTH_DAY_PHONE.png`, so for a person
|
|
|
|
born the 1st of July of 2020, with the phone 4567, the file name for
|
|
|
|
their picture would be `2020_6_1_4567.png`
|
|
|
|
|
2023-07-01 16:33:30 +01:00
|
|
|
## Run the bot
|
|
|
|
|
|
|
|
To get help for the bot command, run:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ ./birthdaybot -help
|
|
|
|
Usage of ./birthdaybot:
|
|
|
|
-config string
|
|
|
|
path to the configuration file (default "birthdaybot.yml")
|
|
|
|
```
|
|
|
|
|
|
|
|
To run the server with the development defaults, run:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ make run
|
|
|
|
```
|
|
|
|
|
2023-06-29 17:55:13 +01:00
|
|
|
## Roadmap
|
|
|
|
|
2023-07-01 16:31:09 +01:00
|
|
|
- [X] Create the bot scaffold
|
2023-06-30 08:58:21 +01:00
|
|
|
- [X] Define how to read the birthdays info
|
2023-06-30 09:38:29 +01:00
|
|
|
- [X] Add a logger instance to the config
|
2023-07-10 13:55:25 +01:00
|
|
|
- [X] Add config validation on server creation
|
2023-07-04 11:48:16 +01:00
|
|
|
- [X] Add options to the server
|
|
|
|
- [X] Pass logger to the server through an option
|
2023-07-10 13:55:25 +01:00
|
|
|
- [X] Configure logger through config (levels and such)
|
2023-07-10 18:58:55 +01:00
|
|
|
- [X] Reduce logger verbosity (through levels)
|
2023-07-10 20:31:54 +01:00
|
|
|
- [X] Add pictures to birthday notifications
|
2023-07-10 19:46:12 +01:00
|
|
|
- [X] Create a configurable template to fill with each notification
|
2023-07-11 12:27:50 +01:00
|
|
|
- [X] Add some endpoints
|
|
|
|
- [X] Health endpoint
|
|
|
|
- [X] Next birthdays endpoint
|
2023-07-11 11:09:08 +01:00
|
|
|
- [ ] Birthday list endpoint
|
2023-07-11 12:27:50 +01:00
|
|
|
- [ ] Allow to use a random port in web tests
|
|
|
|
- [ ] Web server should be optional
|
2023-06-29 17:55:13 +01:00
|
|
|
- [ ] Create different message systems to use with the bot
|
2023-07-04 11:29:13 +01:00
|
|
|
- [X] Telegram
|
|
|
|
- [ ] Email
|
|
|
|
- [ ] Mattermost
|
2023-06-29 17:55:13 +01:00
|
|
|
- [ ] Enjoy!
|