diff options
author | Volpeon <git@volpeon.ink> | 2021-10-17 18:53:04 +0200 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2021-10-17 18:53:04 +0200 |
commit | cdd3d77d56fd304346c643b8d98b6a1e895fc236 (patch) | |
tree | 949a66c1f4da8b8d807ff0c3584df5ac872799c3 /src/api/e621 | |
parent | Detect if Mastodon token is not set (diff) | |
download | feralbot-cdd3d77d56fd304346c643b8d98b6a1e895fc236.tar.gz feralbot-cdd3d77d56fd304346c643b8d98b6a1e895fc236.tar.bz2 feralbot-cdd3d77d56fd304346c643b8d98b6a1e895fc236.zip |
Support multiple e621 queries, post as unlisted
Diffstat (limited to 'src/api/e621')
-rw-r--r-- | src/api/e621/index.ts | 6 |
1 files changed, 4 insertions, 2 deletions
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({ | |||
27 | }); | 27 | }); |
28 | 28 | ||
29 | export async function randomPost() { | 29 | export async function randomPost() { |
30 | const page = Math.floor(Math.random() * (config.e621.maxPage - 1)) + 1; | 30 | const queryIndex = Math.floor(Math.random() * config.e621.queries.length); |
31 | const query = config.e621.queries[queryIndex]; | ||
32 | const page = Math.floor(Math.random() * (query.maxPage - 1)) + 1; | ||
31 | 33 | ||
32 | const response = await client | 34 | const response = await client |
33 | .get("https://e926.net/posts.json", { | 35 | .get("https://e926.net/posts.json", { |
34 | searchParams: { | 36 | searchParams: { |
35 | limit: 75, | 37 | limit: 75, |
36 | page, | 38 | page, |
37 | tags: config.e621.tags.join(" "), | 39 | tags: query.tags.join(" "), |
38 | }, | 40 | }, |
39 | }) | 41 | }) |
40 | .json<{ posts: readonly Post[] }>(); | 42 | .json<{ posts: readonly Post[] }>(); |