The following is a repackaging of content presented by Mark Easton and Robin Davis during a LACUNY Emerging Technology Committee meeting on December 15th, 2015.
Mark Eaton and Robin Davis suggested Peter Organisciak's guide as another good resource to learn how to create a Twitter Bot.
Please see Robin Davis' Github page.
See the "Download ZIP" button toward the upper right. Click it and save the folder to your desktop.
Go to http://twitter.com and sign up for a new account of your choosing.
Go to http://apps.twitter.com and create a new app
Copy Consumer Key/Secret and Access Key/Secret to credentials.py
This script is a basic Twitter bot. It will tweet three things from a list inside the script.
Right-click on mybot.py and select Edit with IDLE
Take a look at the script; Robin and Mark will talk about what it's doing
Select Run > Run Module from the window's menu bar
Change it up!
This script sends out five tweets from the first five lines of an external .txt file.
Right-click on mybot.py and select Edit with IDLE
Right-click on twain.txt and open it in Notepad
Take a look at both files; Robin and Mark will talk about what the script is doing
Select Run > Run Module from the window's menu bar for mybot2.py
Change it up!
This script treats The Red Wheelbarrow as a mad-lib, filling in three blanks from two data sources: JSON files from @dariusk's collection of corpora.
This script from Mark tweets a random line from a .txt file whenever @jasonchowbot tweets.
This script uses a Markov chain to create new sentences from another text, and tweets them.
Mark Eaton and Robin Davis pointed the class to a good Python cheat sheet here.
Here is some downloadable data that can be 'mined' while learning how to build your first bot.
Some bot examples here.