https://github.com/astrowonk/mastodon_hurricane_bot
Python script that posts Hurricane updates from the NHC Atlantic RSS Feed
https://github.com/astrowonk/mastodon_hurricane_bot
bot hurricanes mastodon nhc python weather
Last synced: 2 months ago
JSON representation
Python script that posts Hurricane updates from the NHC Atlantic RSS Feed
- Host: GitHub
- URL: https://github.com/astrowonk/mastodon_hurricane_bot
- Owner: astrowonk
- License: gpl-3.0
- Created: 2023-09-23T14:49:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-08-16T20:47:04.000Z (11 months ago)
- Last Synced: 2025-08-16T22:17:32.492Z (11 months ago)
- Topics: bot, hurricanes, mastodon, nhc, python, weather
- Language: Python
- Homepage: https://vmst.io/@nhc_atlantic_bot
- Size: 150 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tropical Weather (Atlantic) Updates to Mastodon
## This Mastodon bot is posting during hurricane system [hosted on vmst.io](https://vmst.io/@nhc_atlantic_bot).
This grabs the [NHC Atlantic RSS Feed](https://www.nhc.noaa.gov/aboutrss.shtml), 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.