From ed06d3145d13281f758abf0c869c9e67022e2f07 Mon Sep 17 00:00:00 2001 From: Caleb Denio Date: Thu, 24 Dec 2020 12:49:55 -0500 Subject: [PATCH] Track last_valid_ts and add leaderboard emojis --- pkg/jia/handlers.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/jia/handlers.go b/pkg/jia/handlers.go index f3c41c6..28f4fd8 100644 --- a/pkg/jia/handlers.go +++ b/pkg/jia/handlers.go @@ -82,6 +82,7 @@ func onMessage(slackClient *slack.Client, event *slackevents.MessageEvent) { // Finally! redisClient.Set("last_valid_number", matchedNumber, 0) + redisClient.Set("last_valid_ts", event.TimeStamp, 0) redisClient.Set("last_sender_id", event.User, 0) // Get the current month/year in UTC @@ -142,8 +143,17 @@ func HandleLeaderboardSlashCommand(w http.ResponseWriter, r *http.Request) { ), } - for _, v := range entries { - blocks = append(blocks, slack.NewSectionBlock(slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("<@%s> has counted *%d* this month", v.User, v.Number), false, false), nil, nil)) + for i, v := range entries { + emoji := "" + if i == 0 { + emoji = ":first_place_medal:" + } else if i == 1 { + emoji = ":second_place_medal:" + } else if i == 2 { + emoji = ":third_place_medal:" + } + + blocks = append(blocks, slack.NewSectionBlock(slack.NewTextBlockObject("mrkdwn", fmt.Sprintf("%s <@%s> has counted *%d* this month", emoji, v.User, v.Number), false, false), nil, nil)) } resp, _ := json.Marshal(map[string]interface{}{