mirror of
https://github.com/cjdenio/jia.git
synced 2024-11-25 17:13:56 +00:00
Track last_valid_ts and add leaderboard emojis
This commit is contained in:
parent
0a3d526649
commit
ed06d3145d
1 changed files with 12 additions and 2 deletions
|
@ -82,6 +82,7 @@ func onMessage(slackClient *slack.Client, event *slackevents.MessageEvent) {
|
||||||
|
|
||||||
// Finally!
|
// Finally!
|
||||||
redisClient.Set("last_valid_number", matchedNumber, 0)
|
redisClient.Set("last_valid_number", matchedNumber, 0)
|
||||||
|
redisClient.Set("last_valid_ts", event.TimeStamp, 0)
|
||||||
redisClient.Set("last_sender_id", event.User, 0)
|
redisClient.Set("last_sender_id", event.User, 0)
|
||||||
|
|
||||||
// Get the current month/year in UTC
|
// Get the current month/year in UTC
|
||||||
|
@ -142,8 +143,17 @@ func HandleLeaderboardSlashCommand(w http.ResponseWriter, r *http.Request) {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range entries {
|
for i, 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))
|
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{}{
|
resp, _ := json.Marshal(map[string]interface{}{
|
||||||
|
|
Loading…
Reference in a new issue