mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-01 17:48:15 +08:00
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
const utils = require('../utils');
|
|
|
|
module.exports = async (ctx) => {
|
|
const id = ctx.params.id;
|
|
// For compatibility
|
|
const { exclude_replies, include_rts, count } = utils.parseRouteParams(ctx.params.routeParams);
|
|
const client = await utils.getAppClient();
|
|
const user_timeline_query = {
|
|
tweet_mode: 'extended',
|
|
exclude_replies,
|
|
include_rts,
|
|
count,
|
|
};
|
|
let screen_name;
|
|
if (id.startsWith('+')) {
|
|
user_timeline_query.user_id = +id.slice(1);
|
|
} else {
|
|
user_timeline_query.screen_name = id;
|
|
screen_name = id;
|
|
}
|
|
const data = await client.v1.get('statuses/user_timeline.json', user_timeline_query);
|
|
const userInfo = data[0].user;
|
|
if (!screen_name) {
|
|
screen_name = userInfo.screen_name;
|
|
}
|
|
const profileImageUrl = userInfo.profile_image_url || userInfo.profile_image_url_https;
|
|
|
|
ctx.state.data = {
|
|
title: `Twitter @${userInfo.name}`,
|
|
link: `https://twitter.com/${screen_name}`,
|
|
image: profileImageUrl,
|
|
description: userInfo.description,
|
|
item: utils.ProcessFeed(ctx, {
|
|
data,
|
|
}),
|
|
};
|
|
};
|