I just made a thing on Twitter. It is a “bot”. This python computer program runs on my computer and retweets Donald Trump’s (https://twitter.com/realDonaldTrump) Twitter account only if the original tweet came from an Android device. Here’s what it looks like for both a tweet from Trump and one that is probably not:
Research (http://varianceexplained.org/r/trump-tweets/) has shown that Donald uses an Android device to tweet whereas his staff tweet as him using other devices (such as iPhones, iPads and Twitter Web Clients). I find it confusing when watching his Twitter feed to see some tweets that he wrote and some his staff wrote. This Twitter account will ONLY retweet ones from an Android device, hopefully screening out (not retweeting) ones from his staff.
On Twitter, you cannot see what Twitter client a person used to tweet a message. That data is attached to the tweet and stored on Twitter’s servers and you can use its API (https://dev.twitter.com/docs) to get the data. People can follow my bot (https://twitter.com/IsItTrump) on Twitter and get only the Android ones that are most likely tweeted by Trump.
Another reason to write this was that I wanted to make a Twitter bot myself and this seemed like a good project.
Wait. I See a Problem.
Yes. There are several.
- What if his staffers start using an Android device to tweet?
- What if he gets an iPhone instead of his Android?
- How do we “know” it really is Donald Trump tweeting any of this?
I recognize these, am ignoring them and still find this script/bot useful for now.
Can You Post the Code?
Of course. The code is at https://github.com/WebBreacher/twitterretweeterbot for your downloading, usage and improvement.
Pieces of the script:
- You must have a Twitter app created and accessible API keys (they are free).
- Place those in the creds.py file.
- Put all the code on a system that has Python and the Tweepy module (You can most likely pip install tweepy if you do not have it on your system.)
- Run the script.
- It will create a file in /tmp/trumpbot_lasttweet with the number of the last tweet it analyzed.
- I’ve added it to my “cron” (scheduled tasks) on a linux server so that it runs every 2 minutes.
Updated – 2016-12-15
I just noticed that, if the original tweeter deletes their original tweet then IsItTrump’s retweet shows the below content:
We can’t have our retweets disappearing now can we? So, I took the suggestion of @Mubix to make a screenshot of the original tweet and tweet a pic of the original instead of retweeting a tweet. I used @lanmaster53‘s Peepingtom project to get how to call the phantomjs file right (to get the screenshot). Now the tweets from @IsItTrump look like the image below with the original content preserved!
Update – 2017-05-29
Since Trump started using an iPhone for his tweeting several months after his inauguration, this bot was less helpful as a discriminator to help people figure out “was it Trump that tweeted or his staff?” But it remains helpful as an archive of his tweets and the first reply that was tweeted to those tweets. I’ve found that these “replies” to Trump are sometimes more interesting than his original tweet! Here is an example of what the bot’s tweets look like now:
Update – 2017-06-10
Some people mentioned that other Trump administration and family accounts were blocking people from seeing their tweets. They asked if I could mod IsItTrump to get their feed and display pics of their tweets too. Yes. Yes I can. And so, as of now, the IsItTrump bot takes a screenshot and then tweets a pic of:
- Donald Trump
- Donald Trump Jr.
- Eric Trump
- Dan Scavino
- Michael Cohen
Let me know if I should be adding others to this list.