From cdd3d77d56fd304346c643b8d98b6a1e895fc236 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 17 Oct 2021 18:53:04 +0200 Subject: Support multiple e621 queries, post as unlisted --- src/api/e621/index.ts | 6 ++++-- src/api/mastodon/index.ts | 1 + src/config.ts | 46 +++++++++++++++++++++++++--------------------- 3 files changed, 30 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/api/e621/index.ts b/src/api/e621/index.ts index 6aa6a35..4748e87 100644 --- a/src/api/e621/index.ts +++ b/src/api/e621/index.ts @@ -27,14 +27,16 @@ export const client = got.extend({ }); export async function randomPost() { - const page = Math.floor(Math.random() * (config.e621.maxPage - 1)) + 1; + const queryIndex = Math.floor(Math.random() * config.e621.queries.length); + const query = config.e621.queries[queryIndex]; + const page = Math.floor(Math.random() * (query.maxPage - 1)) + 1; const response = await client .get("https://e926.net/posts.json", { searchParams: { limit: 75, page, - tags: config.e621.tags.join(" "), + tags: query.tags.join(" "), }, }) .json<{ posts: readonly Post[] }>(); diff --git a/src/api/mastodon/index.ts b/src/api/mastodon/index.ts index 2d8636e..d0de0a0 100644 --- a/src/api/mastodon/index.ts +++ b/src/api/mastodon/index.ts @@ -52,6 +52,7 @@ export async function createStatus( media_ids: [attachmentId], sensitive: true, spoiler_text: spoilerText, + visibility: "unlisted", }, }) .json(); diff --git a/src/config.ts b/src/config.ts index f051888..4c9f0be 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,34 +1,38 @@ export default { e621: { userAgent: "@feralbot@botsin.space (by RedFoxxo)", - tags: [ - "feral", - "-anthro", - "-human", - "-meme", - "-humor", - "-photography_(artwork)", - "-portrait", - "-comic", - "-saliva", - "-friendship_is_magic", - "-my_little_pony", - "-type:swf", - "-type:webm", - "-type:gif", - "status:active", - "score:>=20", - "inpool:false", + queries: [ + { + tags: [ + "feral", + "-anthro", + "-human", + "-meme", + "-humor", + "-photography_(artwork)", + "-portrait", + "-comic", + "-saliva", + "-friendship_is_magic", + "-my_little_pony", + "-type:swf", + "-type:webm", + "-type:gif", + "status:active", + "score:>=20", + "inpool:false", + ], + maxPage: 131, + }, ], - maxPage: 131, }, /*misskey: { instance: "https://mk.vulpes.one/", token: process.env.MISSKEY_TOKEN, },*/ mastodon: { - instance: "https://botsin.space/", - token: process.env.MASTODON_TOKEN, + instance: "https://botsin.space/", + token: process.env.MASTODON_TOKEN, }, cw: ["gun"], }; -- cgit v1.2.3-70-g09d2