feat: add lens and farcaster
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'Farcaster',
|
||||
url: 'www.farcaster.xyz',
|
||||
lang: 'en',
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/user/:username',
|
||||
categories: ['social-media'],
|
||||
example: '/farcaster/user/vitalik.eth',
|
||||
parameters: { username: 'Farcaster username' },
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['warpcast.com/:username'],
|
||||
target: '/user/:username',
|
||||
},
|
||||
],
|
||||
name: 'Farcaster User',
|
||||
maintainers: ['DIYgod'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const username = ctx.req.param('username');
|
||||
|
||||
const user = (await got(`https://client.warpcast.com/v2/user-by-username?username=${username}`)).data.result.user;
|
||||
|
||||
const casts = (await got(`https://client.warpcast.com/v2/casts?fid=${user.fid}&limit=100`)).data.result.casts;
|
||||
|
||||
return {
|
||||
title: `${user.displayName} on Farcaster`,
|
||||
link: `https://warpcast.com/${username}`,
|
||||
item: casts.map((item) => ({
|
||||
title: item.text,
|
||||
description: `${item.parentAuthor ? `Replying to @${item.parentAuthor.username}: ` : ''}${item.text} ${item.embeds?.urls?.map((url) => `<a href="${url.openGraph.url}">${url.openGraph.title}</a>`).join(' ') || ''} ${item.embeds?.images?.map((image) => `<img src="${image.url}" />`).join(' ') || ''}`,
|
||||
link: `https://warpcast.com/${username}/cast/${item.hash}`,
|
||||
pubDate: new Date(item.timestamp).toUTCString(),
|
||||
guid: item.hash,
|
||||
})),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'Lens',
|
||||
url: 'www.lens.xyz',
|
||||
lang: 'en',
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user