Skip to content

Commit d4a88c7

Browse files
authored
feat(route): Add Chub (#15298)
* Create characters.ts * Create namespace.ts * Update characters.ts * remove uncessary ctx * Update lib/routes/chub/characters.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/chub/characters.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/chub/characters.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/chub/characters.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Moved topics to category field * replaced got with ofetch + query * Update characters.ts * Update lib/routes/chub/characters.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> ---------
1 parent b566ebb commit d4a88c7

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

lib/routes/chub/characters.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { Route } from '@/types';
2+
import ofetch from '@/utils/ofetch';
3+
import { parseDate } from '@/utils/parse-date';
4+
5+
export const route: Route = {
6+
path: '/characters',
7+
categories: ['new-media'],
8+
example: '/chub/characters',
9+
name: 'Characters',
10+
maintainers: ['flameleaf'],
11+
handler,
12+
};
13+
14+
15+
async function handler() {
16+
const hostURL = 'https://www.chub.ai/characters';
17+
const apiURL = 'https://api.chub.ai/api/characters/search';
18+
const data = await ofetch(apiURL, {
19+
headers: { Accept: 'application/json' },
20+
query: {
21+
query: '',
22+
first: 200,
23+
page: 1,
24+
sort: 'last_activity_at',
25+
asc: 'false',
26+
include_forks: 'false',
27+
nsfw: 'true',
28+
nsfl: 'true',
29+
nsfw_only: 'false',
30+
require_images: 'false',
31+
require_example_dialogues: 'false',
32+
require_alternate_greetings: 'false',
33+
require_custom_prompt: 'false',
34+
exclude_mine: 'false',
35+
venus: 'true',
36+
chub: 'true',
37+
min_tokens: 50,
38+
require_expressions: 'false',
39+
require_lore: 'false',
40+
mine_first: 'false',
41+
require_lore_embedded: 'false',
42+
require_lore_linked: 'false',
43+
inclusive_or: 'false',
44+
recommended_verified: 'false',
45+
},
46+
});
47+
const nodes = data.nodes;
48+
49+
return {
50+
allowEmpty: true,
51+
title: 'Chub',
52+
link: hostURL,
53+
item: nodes
54+
.map((item) => ({
55+
title: item.name,
56+
description: `${item.tagline}<br><br>${item.description}`,
57+
pubDate: parseDate(item.createdAt),
58+
updated: parseDate(item.lastActivityAt),
59+
link: `${hostURL}/${item.fullPath}`,
60+
author: String(item.fullPath.split('/', 1)),
61+
enclosure_url: item.avatar_url,
62+
enclosure_type: `image/webp`,
63+
category: item.topics,
64+
})),
65+
};
66+
}
67+
68+

lib/routes/chub/namespace.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { Namespace } from '@/types';
2+
3+
export const namespace: Namespace = {
4+
name: 'Chub',
5+
url: 'chub.ai',
6+
};

0 commit comments

Comments
 (0)