by Elizabeth Uselton
The Author: @lizuselton
The Bot in Action: @katherynebutler
Github: ElizabethU
This project is a basic twitterbot I built to prank my classmates. The bot superficially appears to be a weird human who is really determined to be friends with you. It's kind of like the experience of being facebook friends with your parents. It is one of my first toy projects playing around with APIs. It has undergone minor refactoring. I hope to extract things into classes for further refactoring, as well as add new features.
The bot does three things, mainly.
-
Favorites and retweets an adjustable percentage of tweets of a primary target, and fewer tweets for a text file of secondary targets.
-
Tweets random but sensical tweets on a variety of subjects. The subject is read randomly from a text file, and the searches for a tweet with the topic, and steals the text, sometimes with suprising results. Tweets are filtered for undesirable words read from another text file. It is suggested that you add the @ symbol and the tiny pic url, as the bot tweeting replies or pictures would cause problems and spam people you are not trying to prank.
-
Replies with a random reply from an additional text file.
Pranks are fun, but please don't use this bot for evil. Evil, I will loosely describe as spamming people you don't know, and/or scaring people into thinking they have a stalker.
You will need to use a cronjob to get the bot to post automatically. The bot is programmed to not post between midnight and 8 am PST, if on a server se to UTC. Otherwise, this time will need to be adjusted in the wakey_wakey method of the main class.
To get this code to work, you will need te following text files:
-
A hobbies text file with a list of hobbies. Kathy Butler's is provided as a sample. Please substitute different interests for a different personality.
-
A last tweeted file which will start blank
-
A list of people for the twitterbot to favorite and retweet things of
-
A list of possible responses
-
A list of words you want to censor. People say some awful things on twitter, and also you'll want to filter anything with pictures or directly talking to other users.
Additionally, you will need a yaml file with your twitter configurations.