[liveposting] Add some debug logging to post creation

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-08-31 10:54:05 +02:00
parent 60146d4fe1
commit d7b74f4d6c
Signed by: luzifer
GPG Key ID: 0066F03ED215AD7D

View File

@ -223,6 +223,11 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
m.lock.Lock()
defer m.lock.Unlock()
logger := log.WithFields(log.Fields{
"user": username,
"game": game,
})
postText := strings.NewReplacer(
"${displayname}", displayName,
"${username}", username,
@ -246,6 +251,7 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
return errors.Wrap(err, "parsing message timestamp")
}
if msg.Content == postText && time.Since(mt) < ignoreTime {
logger.Debug("Not creating live-post, it's already there")
return nil
}
}
@ -290,6 +296,8 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
URL: strings.Join([]string{"https://www.twitch.tv", username}, "/"),
}
logger.Debug("Creating live-post")
msg, err := m.discord.ChannelMessageSendComplex(channelID, &discordgo.MessageSend{
Content: postText,
Embed: msgEmbed,
@ -300,6 +308,7 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
// @attr auto_publish optional bool "false" Automatically publish (crosspost) the message to followers of the channel
if m.attrs.MustBool("auto_publish", ptrBoolFalse) {
logger.Debug("Auto-Publishing live-post")
if _, err = m.discord.ChannelMessageCrosspost(channelID, msg.ID); err != nil {
return errors.Wrap(err, "publishing message")
}