Skip to content

Commit

Permalink
feat: twitter 回复和转推 (DIYgod#3809)
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN authored Jan 31, 2020
1 parent f87d381 commit 34db678
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/en/social-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Due to Telegram restrictions, some channels involving pornography, copyright, an

### User timeline

<RouteEn path="/twitter/user/:id" example="/twitter/user/DIYgod" :paramsDesc="['user id']" radar="1" />
<RouteEn path="/twitter/user/:id/:type?" example="/twitter/user/DIYgod" :paramsDesc="['user id', 'Extra options `exclude_replies` exclude replies,`exclude_rts` exclude retweets,`exclude_rts_replies` exclude replies and retweets, for default include all.']" radar="1" />

## User following timeline

Expand Down
2 changes: 1 addition & 1 deletion docs/social-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性

### 用户时间线

<Route author="DIYgod" example="/twitter/user/DIYgod" path="/twitter/user/:id" :paramsDesc="['用户名']" radar="1"/>
<Route author="DIYgod" example="/twitter/user/DIYgod" path="/twitter/user/:id/:type?" :paramsDesc="['用户名', '额外选项 `exclude_replies`去除回复,`exclude_rts`去除转推,`exclude_rts_replies`去除回复和转推,默认包含全部回复和转推。']" radar="1"/>

### 用户关注时间线

Expand Down
2 changes: 1 addition & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ router.get('/jinritoutiao/keyword/:keyword', require('./routes/jinritoutiao/keyw
router.get('/disqus/posts/:forum', require('./routes/disqus/posts'));

// Twitter
router.get('/twitter/user/:id', require('./routes/twitter/user'));
router.get('/twitter/user/:id/:type?', require('./routes/twitter/user'));
router.get('/twitter/list/:id/:name', require('./routes/twitter/list'));
router.get('/twitter/likes/:id', require('./routes/twitter/likes'));
router.get('/twitter/followings/:id', require('./routes/twitter/followings'));
Expand Down
17 changes: 17 additions & 0 deletions lib/routes/twitter/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@ module.exports = async (ctx) => {
}

const id = ctx.params.id;
const type = ctx.params.type;
let exclude_replies = false;
let include_rts = true;
if (type === 'exclude_rts_replies' || type === 'exclude_replies_rts') {
exclude_replies = true;
include_rts = false;
}
if (type === 'exclude_replies') {
exclude_replies = true;
include_rts = true;
}
if (type === 'exclude_rts') {
exclude_replies = false;
include_rts = false;
}
const result = await utils.getTwit().get('statuses/user_timeline', {
screen_name: id,
tweet_mode: 'extended',
exclude_replies,
include_rts,
});
const data = result.data;
const userInfo = data[0].user;
Expand Down

0 comments on commit 34db678

Please sign in to comment.