Skip to content

szad670401/elonmusk-twitter-notifier

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Stonks Twitter Scanner πŸ“ˆ

This little scripts uses the tweepy Python library, which is a wrapper around the Twitter API. It sets up a listener on the @elonmusk Twitter account, and automatically detects whenever Elon Musk posts a tweet mentioning the any of the specified keywords (or any words containing those as substrings).

It also uses AI object detection from images using a YOLO based model that I've custom-trained to detect objects such as dogecoins, bitcoins, doge etc.. in the images.

When a new tweet that meets the conditions is read, this program will automatically e-mail me with the transcript of that tweet. For tweets containing an image that the AI classifies as ones containing objects it's trained to detect, the image will be attached as well. This is a way for me to always be up to date with stocks that may soon rise in value 🀑

Prerequisites πŸ—‚

In order to run this locally, make sure you're Python interpreter is between v3.6 and 3.8 - this is due to the fact that Tensorflow won't work with newer versions. If you're on a newer Python version, consider downgrading with pyenv.

To install all the necessary dependencies, simply run the following command inside project root πŸ‘‡πŸ»

$ pip install -r requirements.txt

Note: I have not included my trained AI model in the repository due to the large file size - you can get it by navigating to the releases tab, downloading doge-ai.h5 and placing it in the root of the project.

Usage and config πŸ‘¨πŸ»β€πŸ’»

If you would like to use this yourself, and receive juicy e-mail notifications every time Elon tweets, you can too! All you have to do is to have a Twitter Developer account and update the following environmental variables with your Twitter API access keys:

# ./src/apiconfig.py

consumer_key = os.getenv('CONSUMER_KEY')
consumer_secret = os.getenv('CONSUMER_SECRET')
access_token = os.getenv('ACCESS_TOKEN')
access_token_secret = os.getenv('ACCESS_SECRET')

You will also have to update the following with your own e-mail details:

# ./src/emailsender.py

mail_from = os.getenv('EMAIL_FROM')
mail_to = os.getenv('EMAIL_TO')
mail_pw = os.getenv('EMAIL_PW')

You might also have to update the SMTP server and port if you're not using Gmail.

Deployment πŸš€

Unless you want to keep this program running inside an open terminal instance forever, you should think about deploying it somewhere. To do this, first find a platform that suits your needs, such as Heroku, Amazon AWS or MS Azure.

You need to remember to set the same config vars on the server as you've done locally, otherwise the program won't work. You also need to make sure that you install all the necessary dependencies (tweepy) - for most platforms this is done by specifying them inside the requirements.txt file, but some services might need more. You will also have to make sure that your platform does not use Python above v3.8!

Some platforms also charge differently and offer different types of containers, so make sure you find one that suits your needs and dones't cost much.

Dealing with bundle size πŸ“¦

One thing to keep in mind is that because of the large size of the AI model, as well as the size of the tensorflow install, the overall bundle size gets quite big quite quickly. Some platforms (particularly Heroku) limit the bundle size you can deploy (for Heroku it's 500mb), and thus deployment can become troublesome.

Preview πŸ“²

Reveal screenshots

Notification Image attachment
image image


may the stonks be ever in your favour

About

AI driven e-mail notifier for tweets mentioning stock from Elon Musk πŸ“ˆ

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%