A small Python application to do my tweeting for me.
The tweets are read from a ‘.txt’ file and posted to Twitter with their API.
The application is running on my Raspberry Pi and tweets once a day. The result can be seen on my twitter profile.
On the image below the important features of the application is displayed:
The application reads from a file (line 7-8) and sends the next tweet to the method ‘tweetThis(…)’. This method then calls the twitter API to post the tweet. The file is then updated by removing the used tweet from it.
To get the API to work it is initialized by giving it a series of codes and keys which are generated on Twitters developer page, and validating the codes. Python has a nice, neat library (Tweepy) to handle all the fancy API setup and calling, making it easy to use.
My Raspberry Pi runs the application once a day through a Cron job.
I have made some improvements to the application. It now reads from several files with various kinds of tweets. So far I have a file for ‘six-word-stories’ and another for ‘anti jokes’. It is also prepared to add more files with other tweet types in the future. Each file has a line with #tags in the bottom, which is appended to each tweet before it is tweetet.
Another update (V3.0):
The bot no longer deletes used tweets. Instead it moves them to the bottom of the list so it never runs out. The application is now theoretically maintenance-free as it reuses the tweets for eternity. Of course I will still be adding new tweets to keep my twitter just a little interesting, but I no longer have to worry about running out of tweets.