mirror of
https://github.com/misenhower/splatoon2.ink.git
synced 2026-09-12 12:35:17 -05:00
Add a tweet for when a new stage has been posted
This commit is contained in:
@@ -4,6 +4,7 @@ const ScheduleTweet = require('./twitter/ScheduleTweet');
|
||||
const GearTweet = require('./twitter/GearTweet');
|
||||
const SalmonRunTweet = require('./twitter/SalmonRunTweet');
|
||||
const NewWeaponTweet = require('./twitter/NewWeaponTweet');
|
||||
const NewStageTweet = require('./twitter/NewStageTweet');
|
||||
const SplatfestTweet = require('./twitter/SplatfestTweet');
|
||||
|
||||
let tweets = [
|
||||
@@ -11,6 +12,7 @@ let tweets = [
|
||||
new GearTweet,
|
||||
new SalmonRunTweet,
|
||||
new NewWeaponTweet,
|
||||
new NewStageTweet,
|
||||
new SplatfestTweet('na'),
|
||||
new SplatfestTweet('eu'),
|
||||
new SplatfestTweet('jp'),
|
||||
|
||||
32
src/updater/twitter/NewStageTweet.js
Normal file
32
src/updater/twitter/NewStageTweet.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const TwitterPostBase = require('./TwitterPostBase');
|
||||
const { readJson } = require('../utilities');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const stagesPath = path.resolve('storage/stages.json');
|
||||
const splatnetAssetPath = path.resolve('public/assets/splatnet');
|
||||
|
||||
class NewStageTweet extends TwitterPostBase {
|
||||
getKey() { return 'newstage'; }
|
||||
getName() { return 'New Stage'; }
|
||||
|
||||
getStages() {
|
||||
return readJson(stagesPath);
|
||||
}
|
||||
|
||||
getData() {
|
||||
return this.getStages().find(s => s.first_seen == this.getDataTime());
|
||||
}
|
||||
|
||||
getImage(data) {
|
||||
return fs.readFileSync(splatnetAssetPath + data.image);
|
||||
}
|
||||
|
||||
getText(data) {
|
||||
let hours = (data.first_available - this.getDataTime()) / 60 / 60;
|
||||
let duration = (hours == 1) ? '1 hour' : `${hours} hours`;
|
||||
return `The first schedules for ${data.name} have been posted! Start playing the new stage in ${duration}. #splatoon2`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NewStageTweet;
|
||||
@@ -13,6 +13,10 @@ class ScheduleTweet extends TwitterPostBase {
|
||||
return readData('schedules.json');
|
||||
}
|
||||
|
||||
getStages() {
|
||||
return readJson(stagesPath);
|
||||
}
|
||||
|
||||
getData() {
|
||||
return this.getSchedules().regular.find(s => s.start_time == this.getDataTime());
|
||||
}
|
||||
@@ -27,7 +31,7 @@ class ScheduleTweet extends TwitterPostBase {
|
||||
|
||||
getText(data) {
|
||||
// Load known stages
|
||||
let stages = readJson(stagesPath);
|
||||
let stages = this.getStages();
|
||||
|
||||
for (let stage of [data.stage_a, data.stage_b]) {
|
||||
let stageInfo = stages.find(s => s.id == stage.id);
|
||||
|
||||
Reference in New Issue
Block a user