Merge pull request #28 from catgirlinspace/mastodon-improvements

Add Content Wrapper for Splatfest Results
This commit is contained in:
Matt Isenhower
2023-01-03 20:43:55 -08:00
committed by GitHub
7 changed files with 25 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import cron from './cron.mjs';
import { sendStatuses, testStatuses } from './social/index.mjs';
import { updateAll } from './data/index.mjs';
import { warmCaches } from "./splatnet/index.mjs";
import MastodonClient from './social/clients/MastodonClient.mjs';
consoleStamp(console);
dotenv.config();
@@ -12,6 +13,7 @@ const actions = {
cron,
social: sendStatuses,
socialTest: testStatuses,
socialTestMastodon: () => testStatuses([new MastodonClient]),
splatnet: updateAll,
warmCaches,
}

View File

@@ -1,5 +1,6 @@
export default class Status
{
status = null;
contentWrapper = null;
media = [];
}

View File

@@ -42,6 +42,8 @@ export default class MastodonClient extends Client
// Send status
await masto.statuses.create({
status: status.status,
spoilerText: status.contentWrapper,
sensitive: !!status.contentWrapper, // Without the sensitive property the image is still visible
mediaIds,
});
}

View File

@@ -35,6 +35,16 @@ export default class SplatfestResultsStatus extends StatusGenerator
return `Splatfest results: Team ${winningTeam.teamName} wins! #splatfest #splatoon3`;
}
async _getContentWrapper() {
let festival = await this.getFestival();
if (!festival || !festival.hasResults) {
return false;
}
return `${festival.title} Splatfest Results`;
}
/** @param {ScreenshotHelper} screenshotHelper */
async _getMedia(screenshotHelper) {
let media = new Media;

View File

@@ -67,6 +67,7 @@ export default class StatusGenerator
const status = new Status;
status.status = await this._getStatus();
status.contentWrapper = await this._getContentWrapper();
let media = await this.getMedia(screenshotHelper);
if (media && !Array.isArray(media)) {
@@ -87,6 +88,10 @@ export default class StatusGenerator
//
}
async _getContentWrapper() {
//
}
/** @param {ScreenshotHelper} screenshotHelper */
async getMedia(screenshotHelper) {
await this._prepareScreenshotHelper(screenshotHelper);

View File

@@ -36,10 +36,10 @@ export function defaultStatusGeneratorManager() {
);
}
export function testStatusGeneratorManager() {
export function testStatusGeneratorManager(additionalClients) {
return new StatusGeneratorManager(
defaultStatusGenerators(),
[new FileWriter],
[new FileWriter, ...additionalClients],
);
}
@@ -47,6 +47,6 @@ export function sendStatuses() {
return defaultStatusGeneratorManager().sendStatuses();
}
export function testStatuses() {
return testStatusGeneratorManager().sendStatuses(true);
export function testStatuses(additionalClients = []) {
return testStatusGeneratorManager(additionalClients).sendStatuses(true);
}

View File

@@ -9,6 +9,7 @@
"cron": "node app/index.mjs cron",
"social": "node app/index.mjs social",
"social:test": "node app/index.mjs socialTest",
"social:test:mastodon": "node app/index.mjs socialTestMastodon",
"splatnet": "node app/index.mjs splatnet",
"warmCaches": "node app/index.mjs warmCaches"
},