Added preliminary announcement code.
This commit is contained in:
parent
84e624a91b
commit
3fafe8455a
4 changed files with 95 additions and 12 deletions
|
|
@ -94,8 +94,6 @@ func (a *App) loadEnv() error {
|
|||
}
|
||||
|
||||
func (a *App) daily() {
|
||||
fmt.Println("daily trigger")
|
||||
|
||||
chats, err := a.db.Chats().ListChats()
|
||||
if err != nil {
|
||||
a.logger.Error("unable to retrieve chats:", err)
|
||||
|
|
@ -125,6 +123,22 @@ func (a *App) daily() {
|
|||
a.logger.Error("could not retrieve this week's birthdays:", err)
|
||||
}
|
||||
}
|
||||
announce, err := a.db.Announcements().AnnouncementsToday(chat.ID)
|
||||
if err == nil && len(announce) > 0 {
|
||||
sb.WriteString("**<u>📢 Today's Announcements 📢</u>**\n\n")
|
||||
for _, ann := range announce {
|
||||
if ann.Title != "" {
|
||||
sb.WriteString("**")
|
||||
sb.WriteString(ann.Title)
|
||||
sb.WriteString("**")
|
||||
sb.WriteString("\n\n")
|
||||
}
|
||||
sb.WriteString(" * ")
|
||||
sb.WriteString(ann.Content)
|
||||
sb.WriteByte('\n')
|
||||
}
|
||||
sb.WriteByte('\n')
|
||||
}
|
||||
bdays, err := a.db.Birthdays().BirthdaysToday(chat.ID)
|
||||
if err == nil && len(bdays) > 0 {
|
||||
sb.WriteString("**<u>Today's Birthday")
|
||||
|
|
|
|||
Loading…
Reference in a new issue