From 01bb8491c191e74f41137aa0793255e6319340c0 Mon Sep 17 00:00:00 2001 From: William Perron Date: Tue, 21 Nov 2023 19:18:50 -0500 Subject: [PATCH] get absentees from database for scheduled reminder --- cmd/themis-server/main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/themis-server/main.go b/cmd/themis-server/main.go index 589af62..b2ac169 100644 --- a/cmd/themis-server/main.go +++ b/cmd/themis-server/main.go @@ -530,7 +530,20 @@ func main() { case <-ctx.Done(): return case <-notifChan: - _, err := discord.ChannelMessageSend(channelId, "don't forget we have a session next %s!") + absentees, err := store.GetAbsentees(ctx, themis.NextMonday()) + if err != nil { + log.Error().Err(err).Msg("failed to get absentees for next session") + return + } + + var msg string + if len(absentees) == 0 { + msg = "Everybody can make it next Monday, see you then!" + } else { + msg = fmt.Sprintf("%s can't make it next Monday.", strings.Join(absentees, ", ")) + } + + _, err = discord.ChannelMessageSend(channelId, msg) if err != nil { log.Error().Err(err).Msg("failed to send scheduled notification") }