Closed marco97pa closed 3 years ago
I'm envisioning a pretty compact, helper-style function to tuck into the beginning of the twitter_post and twitter_repost functions within tweet.py. The function will compare the content of the new tweet against a the previous 3 tweets' contents, and if the new tweet is a duplicate it will terminate the function before it sends the tweet.
This function could also be tweaked to work with image and video tweets, although it will be more involved compared to configure compared to the text tweets.
Am I missing anything here?
I'm envisioning a pretty compact, helper-style function to tuck into the beginning of the twitter_post and twitter_repost functions within tweet.py. The function will compare the content of the new tweet against a the previous 3 tweets' contents, and if the new tweet is a duplicate it will terminate the function before it sends the tweet.
This function could also be tweaked to work with image and video tweets, although it will be more involved compared to configure compared to the text tweets.
Am I missing anything here?
You are absolutely right. I had the same idea but no time to actually develop it.
Why it is needed
It can happen that the bot posts a tweet and then fails (usually because of wrong responses from some sources such as Instagram, Spotify and so on..)
The next time the script executes, it will retry to post the same identical tweet, causing the multiple Tweets bug.
Improvements to your idea
To check if a media has already been posted, just check if the description (the text) of the Tweet is the same. The tweet posted by the bot ALWAYS contain a description so we can easily compare it.
Before terminating the function, there should be a print("WARNING: This tweet has already been sent")
or something similar.
If you have time, you can actually fork the repo, add the function, make the changes and send a pull request.
I will add your name to the contributions and I will share a tweet to thank you from the bot account (assuming that you are on Twitter)
Before posting we should check if the tweet we are going to post is the same as the last one (or the last 3) already posted