mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-09-09 17:15:51 -05:00
Merge pull request #49 from FieryFlames/threads
Initial Threads updater
This commit is contained in:
@@ -30,3 +30,7 @@ MASTODON_ACCESS_TOKEN=
|
||||
BLUESKY_SERVICE=https://bsky.social
|
||||
BLUESKY_IDENTIFIER=splatoon3.ink # Handle or email address
|
||||
BLUESKY_PASSWORD=
|
||||
|
||||
# Threads API parameters
|
||||
THREADS_USERNAME=
|
||||
THREADS_PASSWORD=
|
||||
|
||||
@@ -7,6 +7,7 @@ import { warmCaches } from "./splatnet/index.mjs";
|
||||
import MastodonClient from './social/clients/MastodonClient.mjs';
|
||||
import ImageWriter from './social/clients/ImageWriter.mjs';
|
||||
import BlueskyClient from './social/clients/BlueskyClient.mjs';
|
||||
import ThreadsClient from './social/clients/ThreadsClient.mjs';
|
||||
import { archiveData } from './data/DataArchiver.mjs';
|
||||
|
||||
consoleStamp(console);
|
||||
@@ -19,6 +20,7 @@ const actions = {
|
||||
socialTestMastodon: () => testStatuses([new MastodonClient]),
|
||||
socialTestBluesky: () => testStatuses([new BlueskyClient]),
|
||||
socialTestImage: () => testStatuses([new ImageWriter]),
|
||||
socialTestThreads: () => testStatuses([new ThreadsClient]),
|
||||
splatnet: updatePrimary,
|
||||
splatnetAll: updateAll,
|
||||
warmCaches,
|
||||
|
||||
28
app/social/clients/ThreadsClient.mjs
Normal file
28
app/social/clients/ThreadsClient.mjs
Normal file
@@ -0,0 +1,28 @@
|
||||
import sharp from "sharp";
|
||||
import threads from "threads-api";
|
||||
import Client from "./Client.mjs";
|
||||
|
||||
export default class ThreadsClient extends Client {
|
||||
key = "threads";
|
||||
name = "Threads";
|
||||
|
||||
#api;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.#api = new threads.ThreadsAPI({
|
||||
username: process.env.THREADS_USERNAME,
|
||||
password: process.env.THREADS_PASSWORD,
|
||||
});
|
||||
}
|
||||
|
||||
async send(status, generator) {
|
||||
let jpeg = await sharp(status.media[0].file).jpeg().toBuffer();
|
||||
|
||||
await this.#api.publish({
|
||||
text: status.status,
|
||||
image: { type: "image/jpeg", data: jpeg },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import EggstraWorkStatus from "./generators/EggstraWorkStatus.mjs";
|
||||
import EggstraWorkUpcomingStatus from "./generators/EggstraWorkUpcomingStatus.mjs";
|
||||
import BlueskyClient from "./clients/BlueskyClient.mjs";
|
||||
import ChallengeStatus from "./generators/ChallengeStatus.mjs";
|
||||
import ThreadsClient from "./clients/ThreadsClient.mjs";
|
||||
|
||||
function defaultStatusGenerators() {
|
||||
return [
|
||||
@@ -37,6 +38,7 @@ function defaultClients() {
|
||||
new TwitterClient,
|
||||
new MastodonClient,
|
||||
new BlueskyClient,
|
||||
new ThreadsClient,
|
||||
new ImageWriter,
|
||||
];
|
||||
}
|
||||
|
||||
1778
package-lock.json
generated
1778
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,7 @@
|
||||
"social:test:image": "node app/index.mjs socialTestImage",
|
||||
"social:test:mastodon": "node app/index.mjs socialTestMastodon",
|
||||
"social:test:bluesky": "node app/index.mjs socialTestBluesky",
|
||||
"social:test:threads": "node app/index.mjs socialTestThreads",
|
||||
"splatnet": "node app/index.mjs splatnet",
|
||||
"splatnet:all": "node app/index.mjs splatnetAll",
|
||||
"warmCaches": "node app/index.mjs warmCaches",
|
||||
@@ -37,6 +38,7 @@
|
||||
"pinia": "^2.0.22",
|
||||
"puppeteer": "^18.0.3",
|
||||
"sharp": "^0.32.0",
|
||||
"threads-api": "^1.4.0",
|
||||
"twitter-api-v2": "^1.12.7",
|
||||
"vue": "^3.2.39",
|
||||
"vue-i18n": "^9.2.2",
|
||||
@@ -51,4 +53,4 @@
|
||||
"tailwindcss": "^3.1.8",
|
||||
"vite": "^3.1.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user