Code Monkey home page Code Monkey logo

mastodon_hurricane_bot's Introduction

Tropical Weather (Atlantic) Updates to Mastodon

This Mastodon bot is posting during hurricane system hosted on vmst.io.

This grabs the NHC Atlantic RSS Feed, specifically "Atlantic Basin Tropical Cyclones" from https://www.nhc.noaa.gov/index-at.xml and generates automated posts to a Mastodon bot with this data.

There are a few functions in the nhc_bot.py script that parse the feed into storm-specific lists of 6-7 items per storm, using lxml.

The Stormy class then takes a list of dictionaries for one storm, and generates text, links, and images for a Mastodon post.

Some somewhat messy condition logic is needed to figure out if an update has occured and if a new post should be made. The main script first checks the etag of the rss feed itself, from the http headers. If the etag has changed, the feed is parsed into storm lists and each Stormy instance for each storm is checked against the last posted information for that storm (written to JSON), to see if the summary text changed.

Finally, before posting, a hash of the image bytes is also checked against the hash of the last posted track image, since sometimes the image data lags behind the RSS feed, and I don't want to post a 2PM image with the 5PM update.

The main script runs as a cron job on a Digital Ocean droplet.

mastodon_hurricane_bot's People

Contributors

astrowonk avatar

Stargazers

 avatar

Watchers

 avatar  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.