diff options
author | Volpeon <git@volpeon.ink> | 2021-10-17 20:12:47 +0200 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2021-10-17 20:12:47 +0200 |
commit | 8544feb5d47df2399d07f69c56bb226ce923849a (patch) | |
tree | c54878cf4c454b1212d27f48da34e02e5f286b1e | |
parent | Support multiple e621 queries, post as unlisted (diff) | |
download | feralbot-8544feb5d47df2399d07f69c56bb226ce923849a.tar.gz feralbot-8544feb5d47df2399d07f69c56bb226ce923849a.tar.bz2 feralbot-8544feb5d47df2399d07f69c56bb226ce923849a.zip |
Added query to exclude dragons
-rw-r--r-- | src/api/e621/index.ts | 2 | ||||
-rw-r--r-- | src/config.ts | 46 | ||||
-rw-r--r-- | src/index.ts | 8 |
3 files changed, 31 insertions, 25 deletions
diff --git a/src/api/e621/index.ts b/src/api/e621/index.ts index 4748e87..c8e0f44 100644 --- a/src/api/e621/index.ts +++ b/src/api/e621/index.ts | |||
@@ -48,5 +48,5 @@ export async function randomPost() { | |||
48 | const postIndex = Math.floor(Math.random() * response.posts.length); | 48 | const postIndex = Math.floor(Math.random() * response.posts.length); |
49 | const post = response.posts[postIndex]; | 49 | const post = response.posts[postIndex]; |
50 | 50 | ||
51 | return post; | 51 | return { queryIndex, post }; |
52 | } | 52 | } |
diff --git a/src/config.ts b/src/config.ts index 4c9f0be..33fdc69 100644 --- a/src/config.ts +++ b/src/config.ts | |||
@@ -1,28 +1,34 @@ | |||
1 | const mainQuery = { | ||
2 | tags: [ | ||
3 | "feral", | ||
4 | "-anthro", | ||
5 | "-human", | ||
6 | "-meme", | ||
7 | "-humor", | ||
8 | "-photography_(artwork)", | ||
9 | "-portrait", | ||
10 | "-comic", | ||
11 | "-saliva", | ||
12 | "-friendship_is_magic", | ||
13 | "-my_little_pony", | ||
14 | "-type:swf", | ||
15 | "-type:webm", | ||
16 | "-type:gif", | ||
17 | "status:active", | ||
18 | "score:>=20", | ||
19 | "inpool:false", | ||
20 | ], | ||
21 | maxPage: 131, | ||
22 | }; | ||
23 | |||
1 | export default { | 24 | export default { |
2 | e621: { | 25 | e621: { |
3 | userAgent: "@feralbot@botsin.space (by RedFoxxo)", | 26 | userAgent: "@feralbot@botsin.space (by RedFoxxo)", |
4 | queries: [ | 27 | queries: [ |
28 | mainQuery, | ||
5 | { | 29 | { |
6 | tags: [ | 30 | tags: [...mainQuery.tags, "-western_dragon"], |
7 | "feral", | 31 | maxPage: 96, |
8 | "-anthro", | ||
9 | "-human", | ||
10 | "-meme", | ||
11 | "-humor", | ||
12 | "-photography_(artwork)", | ||
13 | "-portrait", | ||
14 | "-comic", | ||
15 | "-saliva", | ||
16 | "-friendship_is_magic", | ||
17 | "-my_little_pony", | ||
18 | "-type:swf", | ||
19 | "-type:webm", | ||
20 | "-type:gif", | ||
21 | "status:active", | ||
22 | "score:>=20", | ||
23 | "inpool:false", | ||
24 | ], | ||
25 | maxPage: 131, | ||
26 | }, | 32 | }, |
27 | ], | 33 | ], |
28 | }, | 34 | }, |
diff --git a/src/index.ts b/src/index.ts index 42081e6..34cd5f1 100644 --- a/src/index.ts +++ b/src/index.ts | |||
@@ -4,17 +4,17 @@ import config from "./config"; | |||
4 | 4 | ||
5 | (async () => { | 5 | (async () => { |
6 | if (!config.mastodon.token) { | 6 | if (!config.mastodon.token) { |
7 | console.error("MASTODON_TOKEN not set"); | 7 | console.error("MASTODON_TOKEN not set"); |
8 | return; | 8 | return; |
9 | } | 9 | } |
10 | 10 | ||
11 | console.log("Fetching post..."); | 11 | console.log("Fetching post..."); |
12 | 12 | ||
13 | const post = await e621.randomPost(); | 13 | const { queryIndex, post } = await e621.randomPost(); |
14 | const source = post.sources.length ? post.sources[0] : undefined; | 14 | const source = post.sources.length ? post.sources[0] : undefined; |
15 | const cws = config.cw.filter((w) => post.tags.general.includes(w)); | 15 | const cws = config.cw.filter((w) => post.tags.general.includes(w)); |
16 | 16 | ||
17 | console.log(`Got ${post.id}`); | 17 | console.log(`Got ${post.id} via query ${queryIndex}`); |
18 | console.log(`Downloading image...`); | 18 | console.log(`Downloading image...`); |
19 | 19 | ||
20 | const file = await e621.client.get(post.file.url).buffer(); | 20 | const file = await e621.client.get(post.file.url).buffer(); |