Skip to content

A bot that publishes locations on the England and Wales canal network to Mastodon and previously Twitter

License

Notifications You must be signed in to change notification settings

mattkerlogue/narrowbotR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

narrowbotR

GitHub Repo Status: work in progress lapsedgeographer blog post

narrowbotR (pronounced "narrow-boater")[^1] is a Mastodon and Bluesky bot written in Rand powered by Github Actions that posts a random location on the Canal & River Trust network. Where possible it sources a photo of the location from Flickr, if a Flickr photo is not available it will post an aerial photograph.

The bot is inspired by Matt Dray's now retired londonmapbot which randomly posts a location in the rough vicinity of London every 30 minutes. This bot seeks to do something similar: posting a random location on the UK canal network 4 times per day. At present it only publishes information from the English and Welsh canal network.

The bot previously ran on the botsin.space instance but in December 2024 it was migrated to both mastodon.social and Bluesky. The bot also used to run on Twitter, but this was decommissioned in April 2023 following changes to Twitter's Terms of Service.

The bot works as follows:

  • The data from the Canal and River Trust's open data feeds has been downloaded and aggregated into a single file, only the point-based data at this stage, let's call each item in this data a "feature"
  • A feature at random will be selected from the dataset
  • A search of publicly available photos on Flickr, licensed for sharing, in the vicinity of the feature's position is made
  • The photo metadata is scored and the top-scoring photo selected
  • If there are only a small number of photos returned then an aerial photo of the location sourced from Mapbox will be used
  • A post is constructed to provide the feature's name, the feature's type, an open-street map link to the location, and citation of the author a link to the Flickr page of the photo if a Flickr photo is being used.
  • If the flickr photo has tags then these are re-used to add to the standard hashtags included in the post (up to the character limit of each service)
  • The post is then sent to Mastodon using a custom version of the rtoot::post_toot() function that has been extended to embed location data in the posts's metadata, it is posted to Bluesky using bskyr::bs_post()
  • The feature dataset is created only occasionally and stored in data/all_points.RDS for efficiency

You can read a more detailed explanation of how the bot works in this blog post about the original Twitter version of the bot.


Dev notes

For testing purposes use the following lat/long pairs (these are popular features that should have nearby photos):

  • list(long = -2.03219634864333, lat = 51.3520732144106): Lock 29, Devizes Lock (bottom of Caen Hill flight)
  • list(long = -1.18474539433226, lat = 52.2845877855651): Braunston Tunnel West Portal
  • list(long = -3.08780897790795, lat = 52.9704074998854): Pontcysyllte aqueduct