mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-09-13 11:05:28 -05:00
Merge pull request #28 from catgirlinspace/mastodon-improvements
Add Content Wrapper for Splatfest Results
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export default class Status
|
||||
{
|
||||
status = null;
|
||||
contentWrapper = null;
|
||||
media = [];
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user