Skip to content

Radio Astronomy Live is a simple python script that iteratively searches for tweets using a broad set of keywords. For each keyword, the resultant tweets are further filtered by a narrow set of keywords.

License

Notifications You must be signed in to change notification settings

sdasrc/radio-astronomy-retweeter

Repository files navigation

Radio Astronomy Live - A Simple Twitter Bot written in Tweepy

This is Radio Astronomy Live, a non-spammy twitter bot written in Tweepy. The bot is run periodically on a Heroku Dyno.

How does it work?

Radio Astronomy Live is a simple python script that iteratively searches for tweets using a broad set of keywords. For each keyword, the resultant tweets are further filtered by a narrow set of keywords.

Currently used Search Keys and Filter Keys are below -

Search Filters
radio astronomy radio astro, radio-astro, radioastro, radio sun, radio galax, active galax, NGC
radio telescope radioastro, lofar, gmrt, vla, vlbi, nrao, ska, NGC
radio signal star, galax, pulsar, milky, sun, solar, extragalac, supernova, radio observ, agn, radio jet, NGC
radio supernova radioastro, telescope, observation, research, arxiv, paper, NGC
radio jet radioastro, telescope, observation, research, arxiv, paper, NGC
radio galax radioastro, telescope, observation, research, arxiv, paper, NGC
radio sun radioastro, telescope, observation, research, arxiv, paper
radio NGC radioastro, telescope, observation, research, arxiv, paper

How to run this bot locally?

Understand Twitter's Rules on Automation before starting.

  • Install tweepy.

pip install tweepy

  • Sign up for a Twitter Developer account and create a new application here. A Twitter application is essentially your 'bot' - it will send tweets, direct message, reply, retweet, follow and search Twitter from any email inbox. Generate your a consumer key, consumer secret, access key, and access secret. This bot requires both READ and WRITE Permissions enabled to work.

For your own safety, do not save the keys with the bot. Keep them in a separate file and add it to .gitignore, or store the keys as system variables.

  • retweet.py is the python script that you would run. The script uses Python 3+. Edit the script according to your needs.

  • Searching for a single keywords often results in a large number of irrelevant results. It is therefore advisable to use a secondary set of filters. Update the keydict variable in retweet.py with relevant keywords.

  • Run the bot by

python retweet.py

Optional - Setting up a Heroku repo

  • I use the Flask environment to create a web server in server.py. Feel free to switch to other environments such as Django. Here is the Heroku documentation.

  • Define these dependancies in requirements.txt in the root directory.

    Flask
    heroku
    tweepy
  • Setup the server and the worker in Procfile as
    web: python server.py
    worker: python retweet.py 
  • Push to Heroku repo. Add a scheduler to run it regularly. Heroku has its limitations. Alternatively, consider Cron Job to automate things, or use a Raspberry Pi to keep it alive at all times.

Support

About

Radio Astronomy Live is a simple python script that iteratively searches for tweets using a broad set of keywords. For each keyword, the resultant tweets are further filtered by a narrow set of keywords.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages