Prevent duplicate attribute parsing

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-08-06 21:12:29 +02:00
parent 208e2e8666
commit 56fab109a1
Signed by: luzifer
GPG Key ID: 0066F03ED215AD7D

View File

@ -111,14 +111,15 @@ func (m modLivePosting) fetchAndPostForUsername(usernames ...string) error {
"users": len(users.Data),
}).Trace("Found active streams from users")
// @attr stream_freshness optional duration "5m" How long after stream start to post shoutout
streamFreshness := m.attrs.MustDuration("stream_freshness", ptrDuration(livePostingDefaultStreamFreshness))
for _, stream := range streams.Data {
for _, user := range users.Data {
if user.ID != stream.UserID {
continue
}
// @attr stream_freshness optional duration "5m" How long after stream start to post shoutout
streamFreshness := m.attrs.MustDuration("stream_freshness", ptrDuration(livePostingDefaultStreamFreshness))
if time.Since(stream.StartedAt) > streamFreshness {
// Stream is too old, don't annoounce
return nil