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'; } }