From 9a9c8cdb666e51cf25f3c30715cbf54ae3514df6 Mon Sep 17 00:00:00 2001 From: Matt Isenhower Date: Sat, 25 Nov 2017 14:27:28 -0800 Subject: [PATCH] Use alternate text for the schedule tweet when there's a new stage --- src/updater/twitter/ScheduleTweet.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/updater/twitter/ScheduleTweet.js b/src/updater/twitter/ScheduleTweet.js index ebb2180..a0ccb7c 100644 --- a/src/updater/twitter/ScheduleTweet.js +++ b/src/updater/twitter/ScheduleTweet.js @@ -1,6 +1,9 @@ const TwitterPostBase = require('./TwitterPostBase'); const { captureScheduleScreenshot } = require('../screenshots'); -const { readData } = require('../utilities'); +const { readData, readJson } = require('../utilities'); +const path = require('path'); + +const stagesPath = path.resolve('storage/stages.json'); class ScheduleTweet extends TwitterPostBase { getKey() { return 'schedule'; } @@ -23,6 +26,17 @@ class ScheduleTweet extends TwitterPostBase { } getText(data) { + // Load known stages + let stages = readJson(stagesPath); + + for (let stage of [data.stage_a, data.stage_b]) { + let stageInfo = stages.find(s => s.id == stage.id); + + // If this is the first time the stage has been available, return some different text + if (stageInfo && stageInfo.first_available == data.start_time) + return `New stage ${stage.name} is now open! #splatoon2`; + } + return 'Current Splatoon 2 map rotation'; } }