Update AoC Plugin

They increased the "please don't hit our API more than once every x
minutes" to 15 instead of 10.
If the leaderboard update was for a previous year, note that in the
messages sent.
This commit is contained in:
Brian Buller 2020-12-02 08:40:07 -06:00
parent 973a0944d4
commit a2b03adafd
2 changed files with 8 additions and 3 deletions

View File

@ -56,7 +56,8 @@ func (a *App) initialize() error {
}
// Now initialize the Slack stuff
var slackToken, slackDMid string
var slackToken string
// var slackDmid string
slackToken, err = a.m.getSlackToken()
if err != nil || slackToken == "" {
fmt.Print("Slack API Token: ")

View File

@ -368,7 +368,11 @@ func (s *AoCState) AoCBoardCheckAndUpdate(yr int) {
continue
}
if mbr.Stars != v.Stars {
s.SendSlackMessage(":christmas_tree: "+v.Name+" now has "+strconv.Itoa(v.Stars)+" stars! :christmas_tree:", channelId)
if yr == s.GetLatestYear() {
s.SendSlackMessage(fmt.Sprintf(":christmas_tree: %s now has %d stars! :christmas_tree:", v.Name, v.Stars), channelId)
} else {
s.SendSlackMessage(fmt.Sprintf(":christmas_tree: %s now has %d stars! (%d) :christmas_tree:", v.Name, v.Stars, yr), channelId)
}
}
}
// Save the leaderboard to the db
@ -379,7 +383,7 @@ func (s *AoCState) AoCBoardCheckAndUpdate(yr int) {
func (s *AoCState) AoCBoardNeedsUpdate(yr int) bool {
var freshDt time.Duration
if yr == s.GetLatestYear() {
freshDt, _ = time.ParseDuration("10m")
freshDt, _ = time.ParseDuration("15m") // AoC asks that we not update more than once every 15 minutes
} else {
freshDt, _ = time.ParseDuration("1h")
}