Skip to content

Commit

Permalink
Deletes duplicate tweet posted from Facebook. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
umanghome committed Mar 31, 2018
1 parent dab9420 commit 9ab0e86
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions index.js
Expand Up @@ -12,12 +12,28 @@ twitter.get('statuses/user_timeline', {
screen_name: constants.screen_name
}, (err, tweets, response) => {
if (tweets) {
let prevTweet = null;
tweets.forEach(tweet => {
if (tweet.text.indexOf('Retweeted') === 0 && tweet.text.indexOf('#nodelete') < 0) {
twitter.post('/statuses/destroy/:id', {
id: tweet.id_str
}, () => {});
}

if (prevTweet) {
// Get the first ten characters of both.
let prev = prevTweet.text.slice(0, 10);
let curr = tweet.text.slice(0, 10);

// Delete previous tweet if current and previous have the same first-10 chars.
if (prev.startsWith(curr)) {
twitter.post('/statuses/destroy/:id', {
id: prevTweet.id_str
});
}
}

prevTweet = tweet;
});
}
});

0 comments on commit 9ab0e86

Please sign in to comment.