How does an algorithm tweet a selfie?
tweet = three_line_tweet_maker('main.py')
— recurbot.py (@recurbot) December 13, 2017
A few weeks ago whilst reading a hand-wringing article about how automated content production on YouTube & social media will lead to the inevitable collapse of western civilization, my mind wondered to the idea of social media content algorithms behaving like real social media users. Then the stupid question at the top of this post popped into my head and the stupid answer popped in right afterwards. An algoritm’s selfie would be its source code. I’m a big fan of contextless text robotic tweets, especially @IAM_SHAKESPEARE, and have always wanted to own one of my own. So I filed this in my head under “stupid programming exercise to do when you’ve got nothing on” and got on with my life, which currently involves a lot of redecorating.
Fast-forward to today, where I am in day 2 of what feels like a 2 day cold. I’m too bleary and snotty to concentrate on anything serious like my job, but I’ve also just slept for about 18 hours, so I needed some moderate activity to tire me out in preparation for another long sleep. 2 hours later, I present you with @Recurbot.
Code below, but basically it’s a standard twitter bot that reads itself, chops three random lines out of itself and then tweets them. I chose to make it random, as opposed to sequential, to add a bit of variety to it .
So far I’ve not set this up to be automated yet, it’s just running manually when I execute it on my laptop. I’m going to use this as an excuse to start playing around with pythonanywhere.com to see if I can get it to work there. If I can, i expect i’ll set it up to tweet every 2 hours.
By picking three random lines the bot has 27 unique tweets, whereas going through the code sequentially in 3 line chunks would only give 10, a 170% increase in content !! I’m not sure if I should beef up the code by adding in the module that it currently imports: Random.py, json.py and tweepy.py. Random.py is 726 lines long and obviously most of it isn’t really used in the production of the tweets — only randint is called once to get a number between 0 and 27. The more of this paragraph I write, the more convinced I am to just leave it at 30 lines long and let it have some repetition. After all, the bot that tweets Shakespeare is on it’s 4th run through and it doesn’t make it any less amusing when it pops up in my work feed.
Now die, die, die, die, die. [Dies]
— Willy Shakes (@IAM_SHAKESPEARE) October 18, 2017
Speaking of which, I’m going to finish my off-brand lemsip and go back to bed.