Go to file
Miguel de la Cruz 1747612b86 Adds golangci-lint 2023-07-11 16:43:20 +02:00
client Adds a client and tests for the handlers 2023-07-11 16:29:57 +02:00
cmd/birthdaybot Adds web endpoint 2023-07-11 12:37:56 +02:00
model Adds golangci-lint 2023-07-11 16:43:20 +02:00
notification Remove the ToMap birthday method 2023-07-11 10:21:53 +02:00
parser Adds golangci-lint 2023-07-11 16:43:20 +02:00
server Adds golangci-lint 2023-07-11 16:43:20 +02:00
utils Move get picture to a utils package so it can be reused 2023-07-10 23:09:25 +02:00
.envrc Initial commit 2023-06-29 18:55:13 +02:00
.gitignore Restructures configuration for birthdays and adds pictures directory 2023-07-10 21:08:05 +02:00
.gitlab-ci.yml Adds golangci-lint 2023-07-11 16:43:20 +02:00
Makefile Adds golangci-lint 2023-07-11 16:43:20 +02:00
README.md Make web server optional and allow to use a random port 2023-07-11 15:47:01 +02:00
birthdays.csv Adds next birthdays endpoint 2023-07-11 13:27:50 +02:00
example-config.yml Make web server optional and allow to use a random port 2023-07-11 15:47:01 +02:00
go.mod Adds go mock and generate make target and CI check 2023-07-10 12:29:25 +02:00
go.sum Adds go mock and generate make target and CI check 2023-07-10 12:29:25 +02:00
sample.tmpl Properly parses the template functions, and adds some tests 2023-07-11 10:10:56 +02:00
shell.nix Adds golangci-lint 2023-07-11 16:43:20 +02:00

README.md

pipeline status

Birthday bot

A simple bot that notifies of birthdays, posting the contact information of the subject so you can reach them easily.

Configuration

There is an example configuration file that can be used as a base to create your own configuration, and there is a birthdays example CSV file to load the data.

Template file

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.

There are as well some functions available to be used:

  • getYearsOld: receives the year that a user was born, and returns how old the user is getting.

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

Run the bot

To get help for the bot command, run:

$ ./birthdaybot -help
Usage of ./birthdaybot:
  -config string
        path to the configuration file (default "birthdaybot.yml")

To run the server with the development defaults, run:

$ make run

Roadmap

  • Create the bot scaffold
  • Define how to read the birthdays info
  • Add a logger instance to the config
  • Add config validation on server creation
  • Add options to the server
  • Pass logger to the server through an option
  • Configure logger through config (levels and such)
  • Reduce logger verbosity (through levels)
  • Add pictures to birthday notifications
  • Create a configurable template to fill with each notification
  • Add some endpoints
    • Health endpoint
    • Next birthdays endpoint
    • Birthday list endpoint
  • Allow to use a random port in web tests
  • Web server should be optional
  • Create different message systems to use with the bot
    • Telegram
    • Email
    • Mattermost
  • Enjoy!