const utils = require('./utils'); const config = require('@/config'); module.exports = async (ctx) => { if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) { throw 'Twitter RSS is disabled due to the lack of relevant config'; } const id = ctx.params.id; const result = await utils.getTwit().get('statuses/user_timeline', { screen_name: id, tweet_mode: 'extended', }); const data = result.data; const userInfo = data[0].user; const profileImageUrl = userInfo.profile_image_url || userInfo.profile_image_url_https; ctx.state.data = { title: `${userInfo.name} 的 Twitter`, link: `https://twitter.com/${id}/`, image: profileImageUrl, description: userInfo.description, item: utils.ProcessFeed({ data, }), }; };