Crash course in bot construction

In the Guts of Your DIY Publication portion of the workshop, I mentioned that you could create a simple Twitter Bot to help you get information about your publication out into the world. Here’s how to set one up. It takes a tiny bit of reading, editing, and executing a well-commented Python script.

First, follow these directions by @robincamille to chunk your text and to set up a new twitter account and connect with the API. Then use her script to configure your bot. You can adjust the length of time between tweets by changing the 3600 in time.sleep(3600) # Sleep for 1 hour proportionally (7200 for 2 hours, 900 for 15 minutes).

Robin’s @MechanicalPoe bot (on which is what I based @ReallySystemBot) sources its tweets from a Project Gutenberg text, but you could just as easily create a file of tweet-length messages promoting articles, mentioning authors, sending out your call (though, each tweet needs to be unique; Twitter won’t allow you to tweet the same thing over and over again).

If you are not an administrator on your computer, you might have issues installing some of the python packages (automatically) that you’ll need. You can use a virtual environment to install the necessary modules and get things going. Details on that here.

Robin’s script above expects to run continuously, so executing it on a computer that is always one and connected to the internet is optimal. As she notes, you could adjust this script to run as a cron job if you have server space, but that is a little more involved (and depends on your set-up, of course).

Leave a Reply

Your email address will not be published. Required fields are marked *