Tweepy

A Twitter bot.

Context

Twitter is a social media platform and Tweepy is an API which allows you to create Twitter applications, including bots. The tweepy.py file creates the api and establishes a logger. config.py takes API keys and uses the Tweepy OAuthHandler to verify credientials with the Twitter server. Very often it is tempting to showboat the technologies and intricate design of your projects, but I believe it is just as important to be honest when you have made a mistake. I made a junior error by publishing my original API keys to GitHub. This is problematic because now anyone could put their API keys into a similiar API and run any program under my own Twitter Developer app. This could cost lots of money (By spamming calls) or getting me banned from the platform. I originally attempted to fix this problem by opening the repository in Github Desktop and my first impulse was to revert changes from commit. There were merge conflicts and I added an env virtual environment to run the project locally in this step so I was not able to merge. Then, I attempted to branch the repository in order to create a version where the API keys were not revealed. This did not work because I could not clone a file by the name of "Python.exe". I solved the problem by regenerating the API keys from the Twitter Developer app and storing them safely. Now the project cannot be accessed remotely unless I give someone the keys.

For this project, I used a tutorial from the RealPython website. The bot is able to autoreply to users, fetching mentions and replying "Pleace reach us via DM." The original project filters tweets which contain "Tweepy" to mark them as liked and retweeted. I decided to change this to the words "Kanye" and "Yeezy". However, it became apparent that this would trigger the function too many times and possibly create some sort of spam. I decided to change the parameters to that of a more obscure rapper, "EarlSweatshirt" and his moniker "EarlyMan". The bot also refollows people who have followed the bot once every 60 seconds.

While setting up a Dockerfile and running such code proved easy, the part of the project which involved connecting to AWS was not so. I was able to set up an instance and learn how to connect using PuTTY's SSH connection service, using IP's extracted from the Amazon EC2 console. Firstly, the SSH connection would not go through because of the public key, which was confusing because I had made sure to convert my .pem keypair to a .ppk keypair and I was using a properly configured distro. Secondly, Amazon AWS would not allow me to use the EC2 Serial Console to troubleshoot this issue because my running instances went over the limit of vCPU's that were permissible. While this was saddening, the project is still usable if you have a working EC2 instance with SSH login.

More projects

Flask Notes Api

Using SQLAlchemy, Python, Flask, Connexion, Rest API and JS, CSS and HTML, I created a full stack notes app.

Learn more

Trading Bot

Using QuantConnect and Python, I built a trading bot which tracks the SPX index with a variable stop loss.

Learn more