Add emoji tags to the week's winner(s)

This commit is contained in:
Steve McCoy 2019-08-24 14:36:24 -04:00
parent 216862bc10
commit bd99f95345
1 changed files with 22 additions and 2 deletions

View File

@ -101,9 +101,29 @@ func (p *NewsBid) check(conn bot.Connector, ch string) {
p.bot.Send(conn, bot.Message, ch, fmt.Sprintf("Error checking ngate: %s", err))
return
}
topWon := 0
topSpread := 0
for _, res := range wr {
msg := fmt.Sprintf("%s won %d for a score of %d",
res.User, res.Won, res.Score)
if res.Won > topWon {
topWon = res.Won
}
if len(res.WinningArticles) > topSpread {
topSpread = len(res.WinningArticles)
}
}
for _, res := range wr {
icon := ""
if res.Won == topWon {
icon += "🏆 "
}
if len(res.WinningArticles) == topSpread {
icon += "⭐️ "
}
msg := fmt.Sprintf("%s%s won %d for a score of %d",
icon, res.User, res.Won, res.Score)
if len(res.WinningArticles) > 0 {
msg += "\nWinning articles: " + res.WinningArticles.Titles()
}