Skip to content

Commit

Permalink
chore: do not ping Discord /notifiers (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno authored Oct 13, 2024
1 parent 7cf234f commit 8e7cf03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions pkg/templates/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ func (m *DiscordTemplateManager) GetTemplate(name string) (*template.Template, e
}

allSerializers := map[string]any{
"SerializeLink": m.SerializeLink,
"SerializeDate": m.SerializeDate,
"SerializeNotifier": m.SerializeNotifier,
"SerializeNotifiers": m.SerializeNotifiers,
"SerializeLink": m.SerializeLink,
"SerializeDate": m.SerializeDate,
"SerializeNotifier": m.SerializeNotifier,
"SerializeNotifiers": m.SerializeNotifiers,
"SerializeNotifiersNoLinks": m.SerializeNotifiersNoLinks,
}

m.Logger.Trace().Str("type", name).Msg("Loading template")
Expand Down Expand Up @@ -96,6 +97,14 @@ func (m *DiscordTemplateManager) SerializeNotifiers(notifiers types.Notifiers) s
return strings.Join(notifiersNormalized, " ")
}

func (m *DiscordTemplateManager) SerializeNotifiersNoLinks(notifiers types.Notifiers) string {
notifiersNormalized := utils.Map(notifiers, func(n *types.Notifier) string {
return "`@" + n.UserName + "`"
})

return strings.Join(notifiersNormalized, " ")
}

func (m *DiscordTemplateManager) SerializeNotifier(notifier *types.Notifier) string {
return fmt.Sprintf("<@%s>", notifier.UserID)
}
Expand Down
2 changes: 1 addition & 1 deletion templates/discord/Notifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Nobody is subscribed to any notifications on {{ .Config.GetName }}!
**Validators' notifiers on {{ .Config.GetName }}:**
{{- end }}
{{ range .Entries -}}
- **{{ SerializeLink .Link }}**: {{ SerializeNotifiers .Notifiers }}
- **{{ SerializeLink .Link }}**: {{ SerializeNotifiersNoLinks .Notifiers }}
{{ end }}

0 comments on commit 8e7cf03

Please sign in to comment.