Skip to content

Commit 3413b0c

Browse files
authored
Fix tile lock retrieval and improve cooldown message
1 parent 2578c69 commit 3413b0c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

.github/workflows/paint.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ jobs:
4343
STATE=$(cat data/state.json)
4444
4545
USER_COOLDOWN=$(echo $STATE | jq -r ".users[\"$USERNAME\"] // 0")
46-
TILE_LOCK=$(echo $STATE | jq -r ".tiles[\"$COORD\"].lock_until // 0")
46+
TILE_LOCK=$(echo "$STATE" | jq -r ".tiles[\"$COORD\"]?.lock_until // 0")
4747
4848
# Check user cooldown
4949
if [ "$NOW" -lt "$USER_COOLDOWN" ]; then
50-
REMAIN=$(( ($USER_COOLDOWN - $NOW) / 3600 ))
51-
gh issue comment $ISSUE_NUMBER --body "⏳ You may paint again in ${REMAIN}h."
50+
SECONDS_LEFT=$((USER_COOLDOWN - NOW))
51+
HOURS_LEFT=$(( (SECONDS_LEFT + 3599) / 3600 ))
52+
gh issue comment $ISSUE_NUMBER --body "⏳ You may paint again in approximately ${HOURS_LEFT}h."
5253
exit 0
5354
fi
5455

0 commit comments

Comments
 (0)