MyTwitterBot: A Twitter bot powered by a Recurrent Neural Network (RNN)

Build Status License

alt text

This repository started as an extension of the code of Assigment 2 from Standford's deep leaning course on NLP. After finishing the assignment I tried to transform the code in something useful (you can judge if I achieve that in any form).

I used a RNN to create a language model and with that I created a Twitter bot. There are some corpora in the folder 'data':

With these corpora I created three different Bots: PTBBot, TrumpBot and SakaBot (not very original names, I know). The general ideia is that you can use all sort of different corpora to generate more creative and fun tweets!

For example, using the PTBBot I tweeted wonderfull things like:

alt text

Usage

To install all the required libraries just run:

$ sudo apt-get install python3-pip
$ pip3 install -r requirements.txt

Before you start creating your own amazing tweets you must first register your application on Twitter. So, from now on I am assuming that you have all key information in a file called "key.py" (this file should be in the folder "agent").

First, to perform a complete test you can simply run:

$ python3 src/test/test_all.py

Now, if everything is ok, you can go to the folder 'tutorials' where all bots are located. Let's use the TrumpBot as an example. Before writing any tweet you need to train the model:

$ cd  src/tutorials/TrumpBot
$ python3 train.py

After training, you can interact with the bot to write any number of tweets; just run

$ python3 write.py

All tweets that you wrote from this interaction will be stored on the folder "twitter_draft". Suppose "date.txt" is a text file with some tweets, you can edit this file and then run:

$ python3 post.py ./twitter_draft/date.txt -m 30

The bot will post all tweets in an interval of 30 minutes using the account that you wrote in the file "key.py".

Folders