Skip to content

Commit 67a265f

Browse files
committed
Updated getStories with new filtering modes
1 parent 5b7f354 commit 67a265f

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

js/Akun.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import {ChatClient, StoryClient} from './clients/index.js'
2+
import {ChatClient, StoryClient} from './clients/index.js';
33
import Core from './Core.js';
44
import {ChapterNode, ChatNode, ChoiceNode, ReaderPostNode} from './nodes/index.js';
55
import RealTimeConnection from './RealTimeConnection.js';
@@ -276,16 +276,22 @@ class Akun {
276276
* @param {boolean} [options.contentRating.teen=true] - Teen age rating
277277
* @param {boolean} [options.contentRating.mature=true] - Mature age rating
278278
* @param {boolean} [options.contentRating.nsfw=true] - NSFW
279+
* @param {boolean} [options.contentRating.unrated=true] - Unrated
279280
* @param {Object} [options.storyStatus] - Which story status categories should appear in the results
280281
* @param {boolean} [options.storyStatus.active=true] - On-going stories
281282
* @param {boolean} [options.storyStatus.finished=true] - Finished stories
282283
* @param {boolean} [options.storyStatus.hiatus=true] - Stories that met an untimely pause
284+
* @param {Object} [options.rInteract] - Which story status categories should appear in the results. If all are false, then this filter will be disabled
285+
* @param {boolean} [options.rInteract.none=true] - The classic linear story
286+
* @param {boolean} [options.rInteract.light=true] - There are small alternative routes but only the main story is considered important
287+
* @param {boolean} [options.rInteract.medium=true] - There are multiple important routes and multiple endings
288+
* @param {boolean} [options.rInteract.heavy=true] - There are diverse endings and many options. This story involves programming and is game-like
283289
* @param {string} [options.sort] - How the results are sorted. Values can be:
284290
* - 'active': "Sort by the latest activity in the story, including chat posts"
291+
* - 'hot': "Sort by the most upvoted in 24 hours"
285292
* - 'chapter': "Sort by the latest posted chapter"
286293
* - 'replies': "Sort by the most commented stories"
287294
* - 'like': "Sort by the most liked stories"
288-
* - 'top': "Sort by the most commented stories"
289295
* - 'new': "Show the newest stories"
290296
* @param {string} [options.length] - Filter stories by length. Values can be:
291297
* - 'Any': No filtering
@@ -302,13 +308,20 @@ class Akun {
302308
contentRating: {
303309
teen: true,
304310
mature: true,
305-
nsfw: true
311+
nsfw: true,
312+
unrated: true
306313
},
307314
storyStatus: {
308315
active: true,
309316
finished: true,
310317
hiatus: true
311318
},
319+
rInteract: {
320+
none: true,
321+
light: true,
322+
medium: true,
323+
heavy: true
324+
},
312325
sort: 'active',
313326
length: 'Any'
314327
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "akun-api",
3-
"version": "5.1.0",
3+
"version": "5.2.0",
44
"description": "A module intended to enable easy interactions with Anonkun",
55
"main": "index.js",
66
"type": "module",

test.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async function testStory(akun, storyId) {
130130
res();
131131
}
132132
});
133-
})
133+
});
134134
}
135135

136136
async function testChat(akun, chatId) {
@@ -165,7 +165,7 @@ async function testChat(akun, chatId) {
165165
res();
166166
}
167167
});
168-
})
168+
});
169169
}
170170

171171
async function testPut(akun, chatId) {
@@ -227,15 +227,15 @@ async function testPollChoiceRemoval(akun) {
227227
onChoice(akun, client, node);
228228
for (let choiceId = 0; choiceId < node.choiceValues.length; choiceId++) {
229229
if (node.choiceValues[choiceId] === 'test') {
230-
akun.removeChoiceNodeChoice(node.id, choiceId).then(res => console.log(res))
230+
akun.removeChoiceNodeChoice(node.id, choiceId).then(res => console.log(res));
231231
}
232232
}
233233
});
234234
client.storyThread.on('choiceUpdated', (node) => {
235235
onChoiceUpdated(akun, client, node);
236236
for (let choiceId = 0; choiceId < node.choiceValues.length; choiceId++) {
237237
if (node.choiceValues[choiceId] === 'test') {
238-
akun.removeChoiceNodeChoice(node.id, choiceId, 'sample reason').then(res => console.log(res))
238+
akun.removeChoiceNodeChoice(node.id, choiceId, 'sample reason').then(res => console.log(res));
239239
}
240240
}
241241
});
@@ -246,20 +246,28 @@ async function testPollChoiceRemoval(akun) {
246246
res();
247247
}
248248
});
249-
})
249+
});
250+
}
251+
252+
async function testGetStories(akun) {
253+
const {stories} = await akun.getStories('stories', 1, {sort: 'new'});
254+
stories.forEach((story, i) => {
255+
console.log(i, `${story.t} by ${story.u[0].n}`);
256+
});
250257
}
251258

252259
async function runTests(akun) {
253260
// await testAnonToggle(akun, 'vhHhMfskRnNDbxwzo');
254261
// await testPost(akun, 'vhHhMfskRnNDbxwzo');
255262
await testStory(akun, 'vhHhMfskRnNDbxwzo');
256-
// await testChat(akun, 'oQ2fkvRS4nxjLfSmA');
263+
// await testChat(akun, 'oQ2fkvRS4nxjLfSmA');
257264
// await testChat(akun, 'oWC3WhFDMXqZkAG69');
258265
// await testPut(akun, 'vhHhMfskRnNDbxwzo');
259266
// await testVote(akun, 'TziTddJsppEfr82nh');
260267
// await testPollOpenClose(akun);
261268
// await testBan(akun);
262269
// await testPollChoiceRemoval(akun);
270+
// await testGetStories(akun);
263271
}
264272

265273
async function setup(withRealtime = true) {

0 commit comments

Comments
 (0)