title: Error: tweepy.error.TweepError: [{'code': 187, 'message': 'Status is a duplicate.'}] - How do I stop getting duplicated tweet Id?
body: <p>I have created a twitter bot with tweepy.</p>
  <p>Here are the functions of this bot:</p>
  <ol>
  <li>Search for keyword.</li>
  <li>Retweet.</li>
  <li>Reply with standard message.</li>
  </ol>
  <p>My problem:</p>
  <p>I keep running into duplicate tweets and the program stops.</p>
  <p>What this error is <strong>not</strong>:</p>
  <p>Twitter is not stopping me from replying with the same message.</p>
  <p>What I noticed is that I keep getting the same user id. I have tried many methods to avoid this but they do not work as indented or work for a few moments until they stop working, because of this I have not added any of the methods to this code sample as the result is absolutely the same with different variations.</p>
  <p>Questions:</p>
  <ol>
  <li>How do I stop getting duplicated tweet ids?</li>
  <li>Is there a better method than using api.search such as StreamListener? If so how?</li>
  <li>How do I get the newest tweets instead of random tweets?</li>
  </ol>
  <p>Notice that all three questions are related to the original concept of removing duplicates.</p>
  <p>Full code:</p>
  <pre><code>import tweepy
  import time 
  
  consumer_key = 'MYKEY'
  consumer_secret = 'MYSECRET'    
  key =  'KEY'
  secret =  'SECRET'
  
  auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
  auth.set_access_token(key, secret)
  api = tweepy.API(auth, wait_on_rate_limit=True)
  
  tweetNumber = 20    
  q = &quot;MY SEARCH&quot;
  
  tweets = list(tweepy.Cursor(api.search, q, tweet_mode='extended').items(tweetNumber))
  
  def crashBot():    
  
      for tweet in reversed(tweets):
              
          try:          
                                         
                  if q in tweet.full_text.lower():
                      print(str(tweet.id) + '-' + tweet.full_text)
                      api.update_status(&quot;@&quot; + tweet.user.screen_name + &quot; MY MESSAGE&quot;, tweet.id)
                      api.retweet(tweet.id)                                        
                      print(&quot;done!&quot;)                
                      time.sleep(30)            
          except tweepy.tweepyError as e:
              print(e.reason)
              time.sleep(30)
              
  while True:
      crashBot()    
      time.sleep(30)
  </code></pre>