|
| 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 | + |
0 commit comments