mirror of
https://github.com/misenhower/splatoon2.ink.git
synced 2026-09-09 19:15:23 -05:00
@@ -31,6 +31,10 @@ class GearTweet extends TwitterPostBase {
|
||||
return captureGearScreenshot(now);
|
||||
}
|
||||
|
||||
getPublicImageFilename(data) {
|
||||
return 'gear.png';
|
||||
}
|
||||
|
||||
getText(data) {
|
||||
return `Up now on SplatNet: ${data.gear.name} with ${data.skill.name} #splatnet2`;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ class ScheduleTweet extends TwitterPostBase {
|
||||
return captureScheduleScreenshot(data.regular.start_time, this.globalSplatfestOpenInAllRegions());
|
||||
}
|
||||
|
||||
getPublicImageFilename(data) {
|
||||
return 'schedule.png';
|
||||
}
|
||||
|
||||
globalSplatfestOpenInAllRegions() {
|
||||
let festivals = readData('festivals.json');
|
||||
let time = this.getDataTime();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const mkdirp = require('mkdirp').sync;
|
||||
const { postMediaTweet } = require('../client');
|
||||
const { getTopOfCurrentHour, readJson, writeJson } = require('@/common/utilities');
|
||||
|
||||
@@ -28,6 +29,9 @@ class TwitterPostBase {
|
||||
let text = await this.getText(data);
|
||||
let image = await this.getImage(data);
|
||||
|
||||
// Maybe save the image
|
||||
this.maybeSavePublicImage(data, image);
|
||||
|
||||
// Post to Twitter
|
||||
let tweet = await postMediaTweet(text, image);
|
||||
|
||||
@@ -42,6 +46,15 @@ class TwitterPostBase {
|
||||
}
|
||||
}
|
||||
|
||||
maybeSavePublicImage(data, image) {
|
||||
let filename = this.getPublicImageFilename(data);
|
||||
if (filename) {
|
||||
let outputFilename = path.resolve(`dist/twitter-images/${filename}`);
|
||||
mkdirp(path.dirname(outputFilename));
|
||||
fs.writeFileSync(outputFilename, image);
|
||||
}
|
||||
}
|
||||
|
||||
async saveTestScreenshot() {
|
||||
try {
|
||||
let data = this.getTestData();
|
||||
@@ -141,6 +154,9 @@ class TwitterPostBase {
|
||||
// The image data to be posted with the Tweet
|
||||
getImage(data) { }
|
||||
|
||||
// The filename to store the image as (optional)
|
||||
getPublicImageFilename(data) { }
|
||||
|
||||
// The text body of the Tweet
|
||||
getText(data) { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user