Skip to content

Commit bb272b6

Browse files
committed
fix replies: true not working
1 parent b77e7a9 commit bb272b6

File tree

5 files changed

+26
-24
lines changed

5 files changed

+26
-24
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ The [Syndication API](https://syndication.twitter.com/srv/timeline-profile/scree
2424

2525
#### ❌ Limitations
2626
- When getting a Timeline, only up to `100` Tweets can be returned. (May be `20` in some cases)
27-
- Replies endpoint is currently broken and `replies: true` will not return anything.
2827

2928
## Authentication
3029
Twitter is now known to require a cookie to return any data!<br>
@@ -137,7 +136,8 @@ Timeline.disablePuppeteer()
137136
```
138137

139138
## Disclaimer
140-
By using this library, you must do so at your own discretion.<br>
139+
You **must** use this library at your own discretion!
140+
141141
I will not be held accountable for any outcomes that may result from its usage, including and not limited to:
142142
- Banning/Suspension of your Twitter account.
143143
- Lawsuits, fines and other Twitter related legal disputes.

src/classes/timeline.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default class Timeline {
119119
options: Partial<TweetOptions> = {}
120120
) {
121121
// Since `replies` could be `any` when compiled, check defined with !!
122-
const endpoint = `${this.url}${username}?showReplies=${!!options.replies}`
122+
const endpoint = `${this.url}${username}`
123123

124124
try {
125125
const parsedCookie = typeof options.cookie === 'string'
@@ -185,7 +185,7 @@ class TimelineTweet {
185185
return this.text.startsWith('RT @')
186186
}
187187

188-
get isReply() {
188+
get isReply() {
189189
return !!this.inReplyToName
190190
}
191191
}

src/tests/timeline.test.ts

+19-16
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,30 @@ describe('Timeline get', async () => {
1818
const cookie = process.env.TWITTER_COOKIE
1919
expect(cookie).toBeDefined()
2020

21-
it.skip('timeline can be retrieved after cutoff', async () => {
22-
let timeline = []
23-
24-
try {
25-
timeline = await Timeline.get('elonmusk')
26-
} catch(e) {
27-
console.error(e)
28-
} finally {
29-
expect(timeline).toBeDefined()
30-
assertType<TimelineTweet[]>(timeline)
31-
expect(timeline.length).toBeGreaterThan(0)
32-
33-
const latestTweetDate = new Date(timeline[0].createdAt).getTime()
34-
expect(latestTweetDate / 1000).toBeGreaterThan(1651363200)
35-
}
36-
})
21+
// it.skip('timeline can be retrieved after cutoff', async () => {
22+
// let timeline = []
23+
24+
// try {
25+
// timeline = await Timeline.get('elonmusk')
26+
// } catch(e) {
27+
// console.error(e)
28+
// } finally {
29+
// expect(timeline).toBeTruthy()
30+
// expect(timeline).toBeDefined()
31+
// assertType<TimelineTweet[]>(timeline)
32+
// expect(timeline.length).toBeGreaterThan(0)
33+
34+
// const latestTweetDate = new Date(timeline[0].createdAt).getTime()
35+
// expect(latestTweetDate / 1000).toBeGreaterThan(1651363200)
36+
// }
37+
// })
3738

3839
it('can use puppeteer with no config', async () => {
3940
await Timeline.usePuppeteer()
4041
const timeline = await Timeline.get('elonmusk', { cookie })
4142
Timeline.disablePuppeteer()
4243

44+
expect(timeline).toBeTruthy()
4345
expect(timeline).toBeDefined()
4446
assertType<TimelineTweet[]>(timeline)
4547
expect(timeline.length).toBeGreaterThan(0)
@@ -98,6 +100,7 @@ describe('Timeline get', async () => {
98100
try {
99101
timeline = await Timeline.get('rileyreidx3', { cookie })
100102
} finally {
103+
expect(timeline).toBeTruthy()
101104
expect(timeline).toBeDefined()
102105
assertType<TimelineTweet[]>(timeline)
103106
expect(timeline.length).toBeGreaterThan(0)

src/util.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ const buildCookieString = (cookies: TwitterCookies) => {
2727
}
2828

2929
let str = ""
30-
Object.entries(obj).forEach(e => {
31-
str += `${e[0]}=${e[1]}; `
32-
})
30+
Object.entries(obj).forEach(e => str += `${e[0]}=${e[1]}; `)
3331

3432
return str.trimEnd()
3533
}

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
33
"module": "NodeNext",
4-
"target": "ES2017",
54
"moduleResolution": "NodeNext",
5+
"target": "ES2017",
66
"outDir": "dist",
77
"types": ["node"],
88
"skipDefaultLibCheck": true,
@@ -13,6 +13,7 @@
1313
"noEmitOnError": true,
1414
"strictFunctionTypes": true,
1515
"baseUrl": ".",
16+
"removeComments": true,
1617
"paths": {
1718
"tslib" : ["node_modules/tslib/tslib.d.ts"]
1819
}

0 commit comments

Comments
 (0)