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/trumpdroidretweeter 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!