Skip to content
a bot which tweets alphabetised movie lines from the cornell movie lines corpus
Python Shell
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Movie lines bot

What does it do? It tweets one line from an alphabetised list of movie dialogue every five minutes. It was a quick exercise to get my rusty head aroung Twitter bots in 2018 (as opposed to the last time I made them about 5 years ago...).

This bot can be found at @al_film_betical

The setup is fairly simple: I have a Dreamhost account, a Python script, and a file I want to read from. The bot runs as a cron job from my Dreamhost account once every 5 minutes.

Below are the bash instructions to set up this bot on Dreamhost. Most of the files have annotations.

You will need:

  • A username on Dreamhost with access to SSH (or another web provider who'll let you use cron). Note that my username and password have been masked here as 'my-bot' and 'my-dreamhost-server' respectively
  • A Twitter account set up with Developer credentials, and API keys (see here for a nice tutorial)

Note that this file was very useful in setting up my bot!

So, let's begin!

Log into your server via SSH ssh # enter password

Install Python3
(detailed instructions here)

cd ~
mkdir tmp
cd tmp
tar zxvf Python-3.6.2.tgz 
cd Python-3.6.2 
./configure --prefix=$HOME/opt/python-3.6.2
make install
cd ~
nano .bash_profile
# add the following line
export PATH=$HOME/opt/python-3.6.2/bin:$PATH
# ctrl-O to save; enter to confirm; ctrl-x to close; now we're back to bash
# check we have the right python
which python3 
python3 --version
pip3 install --upgrade pip # just to be sure we're up to date
pip3 install virtualenv # not actually necessary, comes pre-installed

Now to make the bot!

virtualenv movielinesbot
cd movielinesbot
pip install tweepy

in a separate shell window create a test file named (just contains print("Hello World")) on local machine

# cd to folder
cd /Users/o/Documents/github-root/bots/movielinesbot/
# scp upload file
# enter password

back to the ssh shell:


if it prints "Hello World" - success!

now scrabble to write python code

I made several files:

  • movie_lines-alphabetised.txt - a clean "movie lines" document - all duplicates removed

  • lines_read.csv - a log file (to log time, number of tweets posted, and tweet content)

  • - a script to post tweets

  • - a bash script to activate the virtualenv, run the python script with authentication, and then deactivate the virtualenv. this isn't included in GitHub as it has my bot credentials in it - you'll have to look through the file here and make some changes to it with your credentials!

  • Change the to be named

  • Put your access keys, secrets and tokens into the bits marked YOUR_TOKEN_HERE etc

  • Change the filepaths to point to the ones you set up earlier

  • then scp entire folder to dreamhost (from non-ssh window):

scp *

back to the ssh window! We need to make the script executable:

chmod +x

then test it:


If it works you'll see a tweet on your account. If not, something messed up and you need to google around and see what went wrong...

Setting a Cron job on Dreamhost

See here for help with this

This is my Cron command - it just fires up the cron in my Dreamhost panel

sh /home/my-bot/movielinesbot/ > /dev/null

Mine runs every five minutes. You can fire yours up whenever you like.

I hope this helps! Enjoy. :)

You can’t perform that action at this time.