Use alternate text for the schedule tweet when there's a new stage

This commit is contained in:
Matt Isenhower
2017-11-25 14:27:28 -08:00
parent 81f35e9a32
commit 9a9c8cdb66

View File

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