I’m going to show you how I created a twitter bot using Python. I wanted to create a twitter bot that I could run on my raspberry pi. I decided to combine the Bitcoin script that I was helped with in a previous post. The script queries the CoinDesk API for current the current Bitcoin price and last years bitcoin price and posts it to twitter every 24 hours.

First you need to create a new twitter account that you are going to use for the bot. To access the twitter API you will need to register a new app, you can use this link. After registering a new app you will need to update the “Application Type” under the permissions tab to “Read and Write”. Under the Keys and Access Tokens tab click “Generate Consumer Key and Secret” you will be provided with an Consumer Key, Consumer Secret, Access Token, and Access Token Secret. You will need this information for you script to login to the twitter API.

Next you need to install Tweepy on the device you will be running the script from. On my raspberry pi I simply typed pip install tweepy

Tweepy installation instructions can be found on GitHub

Use the script below and fill in the Consumer Key, Consumer Secret, Access Token, and Access Token Secret that you generated earlier for your bot. You now have a twitterbot!

Follow my bot on twitter at @Evil_1T

As always I would like any input and feedback on what you guys think. All ideas welcome

My GitHub repository for this project – https://github.com/llamafarmer/twitterbot

Tweepy install – https://github.com/tweepy/tweepy

Twitter Bot – https://twitter.com/Evil_1T

Raspberry Pi 3 (The same one I’m using) – http://amzn.to/2gzPPlz