Skip to content

Commit

Permalink
skip duplicate content check
Browse files Browse the repository at this point in the history
  • Loading branch information
alphabiz-se4 committed Jun 17, 2023
1 parent e6f13e2 commit c52892b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions publicTwitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ const publicTwitter = async (describe) => {
accessToken: process.env.TWITTER_ACCESS_TOKEN_KEY,
accessSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET
})
const res = await twitterClient.v2.userTimeline('424858141')
const lastDesc = res._realData.data[0].text
const tweetList = res._realData.data
// const res = await twitterClient.v2.userTimeline('424858141')
// const lastDesc = res._realData.data[0].text
// const tweetList = res._realData.data

for (const tweetObj of tweetList) {
const lastDesc = tweetObj.text
// console.log(tweetObj)
// console.log('------------------------')
if (describe === lastDesc + '\n' || describe === lastDesc.replace(/\r/gm, '\n')) {
console.log('duplicate content!')
return false
}
}
// for (const tweetObj of tweetList) {
// const lastDesc = tweetObj.text
// // console.log(tweetObj)
// // console.log('------------------------')
// if (describe === lastDesc + '\n' || describe === lastDesc.replace(/\r/gm, '\n')) {
// console.log('duplicate content!')
// return false
// }
// }
await twitterClient.v2.tweet(describe).catch(err => {
if (!err.data.detail.includes('Tweet with duplicate content')) throw err
})
Expand Down

0 comments on commit c52892b

Please sign in to comment.