UNPKG

rsshub

Version:
99 lines (97 loc) 2.94 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.mjs"; import "./dist-BInvbO1W.mjs"; import { t as logger_default } from "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import "./proxy-Db7uGcYb.mjs"; import "./got-KxxWdaxq.mjs"; import "./invalid-parameter-rr4AgGpp.mjs"; import "./config-not-found-Dyp3RlZZ.mjs"; import "./puppeteer-DGmvuGvT.mjs"; import "./readable-social-DoIL4WB3.mjs"; import { t as api_default } from "./api-DtVrjNN4.mjs"; import { t as utils_default } from "./utils-BmkxbUEd.mjs"; //#region lib/routes/twitter/user.ts const route = { path: "/user/:id/:routeParams?", categories: ["social-media"], view: ViewType.SocialMedia, example: "/twitter/user/_RSSHub", parameters: { id: "username; in particular, if starts with `+`, it will be recognized as a [unique ID](https://github.com/DIYgod/RSSHub/issues/12221), e.g. `+44196397`", routeParams: "extra parameters, see the table above" }, features: { requireConfig: [ { name: "TWITTER_USERNAME", description: "Please see above for details." }, { name: "TWITTER_PASSWORD", description: "Please see above for details." }, { name: "TWITTER_AUTHENTICATION_SECRET", description: "TOTP 2FA secret, please see above for details.", optional: true }, { name: "TWITTER_AUTH_TOKEN", description: "Please see above for details." }, { name: "TWITTER_THIRD_PARTY_API", description: "Use third-party API to query twitter data", optional: true } ], requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "User timeline", maintainers: [ "DIYgod", "yindaheng98", "Rongronggg9", "CaoMeiYouRen", "pseudoyu" ], handler, radar: [{ source: ["x.com/:id"], target: "/user/:id" }] }; async function handler(ctx) { const id = ctx.req.param("id"); const { count, include_replies, include_rts } = utils_default.parseRouteParams(ctx.req.param("routeParams")); const params = count ? { count } : {}; await api_default.init(); const userInfo = await api_default.getUser(id); let data; try { data = await (include_replies ? api_default.getUserTweetsAndReplies(id, params) : api_default.getUserTweets(id, params)); if (!include_rts) data = utils_default.excludeRetweet(data); } catch (error) { logger_default.error(error); } const profileImageUrl = userInfo?.profile_image_url || userInfo?.profile_image_url_https; return { title: `Twitter @${userInfo?.name}`, link: `https://x.com/${userInfo?.screen_name}`, image: profileImageUrl.replace(/_normal.jpg$/, ".jpg"), description: userInfo?.description, item: data && utils_default.ProcessFeed(ctx, { data }), allowEmpty: true }; } //#endregion export { route };