mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-07-17 01:44:23 -05:00
add ImageWriter
This commit is contained in:
parent
e93c49348b
commit
9e337ca1ab
|
|
@ -5,6 +5,7 @@ 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';
|
||||
import ImageWriter from './social/clients/ImageWriter.mjs';
|
||||
|
||||
consoleStamp(console);
|
||||
dotenv.config();
|
||||
|
|
@ -14,6 +15,7 @@ const actions = {
|
|||
social: sendStatuses,
|
||||
socialTest: testStatuses,
|
||||
socialTestMastodon: () => testStatuses([new MastodonClient]),
|
||||
socialTestImage: () => testStatuses([new ImageWriter]),
|
||||
splatnet: updateAll,
|
||||
warmCaches,
|
||||
}
|
||||
|
|
|
|||
17
app/social/clients/ImageWriter.mjs
Normal file
17
app/social/clients/ImageWriter.mjs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import fs from 'fs/promises';
|
||||
import mkdirp from 'mkdirp';
|
||||
import Client from "./Client.mjs";
|
||||
|
||||
export default class ImageWriter extends Client {
|
||||
key = 'image';
|
||||
name = 'ImageWriter';
|
||||
|
||||
dir = 'dist/status-screenshots'; // `/screenshots` points to the page used by puppeteer
|
||||
|
||||
async send(status, generator) {
|
||||
await mkdirp(this.dir);
|
||||
|
||||
let imgFilename = `${this.dir}/${generator.key}.png`;
|
||||
await fs.writeFile(imgFilename, status.media[0].file);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import FileWriter from "./clients/FileWriter.mjs";
|
||||
import ImageWriter from "./clients/ImageWriter.mjs";
|
||||
import MastodonClient from "./clients/MastodonClient.mjs";
|
||||
import TwitterClient from "./clients/TwitterClient.mjs";
|
||||
import DailyDropGearStatus from "./generators/DailyDropGearStatus.mjs";
|
||||
|
|
@ -26,6 +27,7 @@ function defaultClients() {
|
|||
return [
|
||||
new TwitterClient,
|
||||
new MastodonClient,
|
||||
new ImageWriter,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@ server {
|
|||
autoindex on;
|
||||
}
|
||||
|
||||
location /status-screenshots/ {
|
||||
add_header Cache-Control no-cache;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
autoindex on;
|
||||
}
|
||||
|
||||
# Gear redirect
|
||||
location ~ /nso/g/(.*) {
|
||||
return 302 https://s.nintendo.com/av5ja-lp1/znca/game/4834290508791808?p=/gesotown/$1;
|
||||
|
|
|
|||
|
|
@ -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:image": "node app/index.mjs socialTestImage",
|
||||
"social:test:mastodon": "node app/index.mjs socialTestMastodon",
|
||||
"splatnet": "node app/index.mjs splatnet",
|
||||
"warmCaches": "node app/index.mjs warmCaches"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user