|
|
|
@ -524,33 +524,30 @@ func main() {
|
|
|
|
|
cancel()
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
|
for {
|
|
|
|
|
select {
|
|
|
|
|
case <-ctx.Done():
|
|
|
|
|
return
|
|
|
|
|
case <-notifChan:
|
|
|
|
|
go notifier.NotifyFunc(ctx, func() {
|
|
|
|
|
absentees, err := store.GetAbsentees(ctx, themis.NextMonday())
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Error().Err(err).Msg("failed to get absentees for next session")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for i, a := range absentees {
|
|
|
|
|
a = fmt.Sprintf("<@%s>", a)
|
|
|
|
|
absentees[i] = a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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, ", "))
|
|
|
|
|
msg = fmt.Sprintf("%s can't make it next Monday.", themis.FormatStringSlice(absentees))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err = discord.ChannelMessageSend(channelId, msg)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Error().Err(err).Msg("failed to send scheduled notification")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
time.Sleep(5 * time.Minute)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
<-ctx.Done()
|
|
|
|
|
log.Info().Msg("context cancelled, exiting")
|
|
|
|
|