Skip to content Skip to sidebar Skip to footer

How Do I Make Sure A Twitter Bot Doesn't Retweet The Same Tweet Multiple Times?

I'm writing a simple Twitter bot in Python and was wondering if anybody could answer and explain the question for me. I'm able to make Tweets, but I haven't had the bot retweet any

Solution 1:

You should store somewhere the timestamp of the latest tweet processed, that way you won't go throught the same tweets twice, hence not retweeting a tweet twice.

This should also make tweet processing faster (because you only process each tweet once).

Solution 2:

I wrote a twitter bot in python a few months ago and this link helped a lot. I also used this github repo which although is in Ruby, was quite helpful for logic flow. This repo uses a similar approach to what you mentioned, creating a local datastore of previous retweets to compare against each tweet.

Solution 3:

This is how I did it. I grabbed the list of things to retweet and a list of my feed. I cut the lists down to only posts within the past 24 hours. Then for each item in retweetable I check to see if it's in my feed list. If not I post RT @user retweet content.

I also wrote a function to chop the str down to 140 chars (137 + '...')

E.G.

TO_RT = 'a post to post'
MYTWT = ('old post', 'other old post')

if TO_RT not in MYTWT
  Tweet(TO_RT)

Solution 4:

Twitter is set such that you can't retweet the same thing more than once. So if your bot gets such a tweet, it will be redirected to an Error 403 page by the API. You can test this policy by reducing the time between each run by the script to about a minute; this will generate the Error 403 link as the current feed of tweets remains unchanged.

Post a Comment for "How Do I Make Sure A Twitter Bot Doesn't Retweet The Same Tweet Multiple Times?"