Giter Club home page Giter Club logo

iss-twitter-bot's Introduction

Note: I have put this project to sleep due to Twitter's recent changes. All bot tweets were deleted by twitter.

I.S.S. Volcano Alert

 

This project has two functionalities, being an API and a Twitter bot.

  • The Twitter bot will send a tweet to a random astronaut aboard the International Space Station when they pass over a volcano on the surface of the Earth.

  • The API keeps track of all of the volcanos the I.S.S. passes over, including the number of times, the top three volcanos the I.S.S. has passed over, as well as data about the most recently passed over volcano.

 

Inspiration


I wanted a project that would take me a long time to work on, and allow me to build my own API. Clocking in at well over 100 hours, not only do I have an API, I have also built a twitter bot, and a website to show the data from my API.

 

How it works


Everything starts with an Open Notify API that delivers the location data for the International Space Station, and who is on board.

 

Every seven seconds, the server hosted on Heroku, checks the coordinates of the I.S.S. to see if it is above a surface volcano. Also within the program, in volcanoLatLongName.js, is a list from The Smithsonian Institution, which has all of Earth's volcanos latitude, longitude, and name.

 

Once the I.S.S. is above a volcano, the variable tweetContent is populated with a message to be tweeted, including a random astronaut name aboard the I.S.S., the coordinates of the volcano, and its name. The tweet is then sent out via a twitter client, and the new volcano data is saved to a JSON file (coords.json). The new volcano, if it does not exist, is added to the passedOverVolcanos object. If the most recent volcano does exist, the number is updated +1. There is also a function that makes and updates the top three most passed over volcanos and makes an array from them.

 

The website takes this data and displays it. It also uses a google maps iframe that updates each time a volcano is passed over to show where the location is what what it looks like.

 

Complications


Because Heroku's free dynos filesystem is ephemeral, and the servers restart every 24 hours, the data from my JSON file is reset. At first, I wanted to keep a running tally of the top three volcanos, but because it resets I changed it to be the top three of the day.

 

I would eventually like to store my volcano data on a database so that I can see what the most passed over volcano truly is.

 

The second complication I had is that heroku is running the LTS version of Node. The native fetch function in Node was introduced in v18. To get around that, I had to use a fetch polyfill from gjuoun. This however, only supported HTTPS requests, and not HTTP. The API I chose used HTTP, so I took gjuoun's polyfill, and with the help of Octoshrimpy, I made the polyfill support HTTP.

 

Credits


The base for my http polyfill was taken from gjuoun.

 

Special thanks to Octoshrimpy for the project idea, as well as the #100Devs discord for help when I had questions.

 

 

License: MIT

iss-twitter-bot's People

Contributors

calarcher avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.