See, I told you that bots have a sense of humor.
Well OK. This bot may be tasked with ONLY tweeting random jokes, but it’s still funny, right?
To get started you’ll need:
- The Raspberry Pi has already been set up.
- And that it is connected to the Internet.
- You know nothing about Python and that you just want a funny
botwithout all of the details.
Great! Let’s get started.
While using the Raspberry Pi create a new folder called ‘funnyBot’ and a new file called ‘bot.py’.
Open up a terminal and install Tweepy and Requests.
The terminal is located in the top-left corner. Click the command prompt icon called ‘Terminal.’
Type the following commands one at a time:
pip3 install tweepy
pip3 install requests
Go to https://developer.twitter.com/ and create an account. Provide details on how the app will be used and submit for review. The application to get a dev
Once the app has been created click on the Permissions tab and click Read, write, and direct messages.
Click the Keys and tokens tab and generate an Access token & access token secret. We will use both consumer API keys and access tokens.
Back on the Raspberry Pi double click ‘bot.py.’ Paste your consumer keys and tokens in the appropriate variable:
Great! You have your program, now we need to schedule it. Install Cron GUI which allows us to schedule a task:
sudo apt-get install gnome-schedule
Next, click on the Raspberry Pi icon in the top-left corner and select System Tools > Scheduled tasks.
Create a new reoccurring task:
Provide a description and then provide the following command (your username may be different):
Confirm that the bot works: You can change the reoccurring job to be every minute to confirm that a joke tweets from your account. Don’t spam yourself!