Huginn is a great piece of software, but the documentation is … a bit sparse. Especially when it comes to details of the agents. I’m going to blog about a couple more more examples in the future.
For another project I’m using Leaflet, a JavaScript library for rendering maps in a browser. New versions are released occasionally, and I want to know when it’s time to update the project website. Huginn can do that.
This needs three agents:
Checking for new versions: Http Status Agent
This agent is used to periodically check the website and see if there is a new released version.
In this case I’m using the GitHub repository as source, and there the latest link. The Releases page has a Latest release link (https://github.com/Leaflet/Leaflet/releases), which is a redirect to the actual version (currently: https://github.com/Leaflet/Leaflet/releases/tag/v1.7.1).
The Huginn agent is configured as follow:
Schedule: pick one, I’m using a weekly timeKeep events: I keep events around for7 days, for debugging purposesUrl:https://github.com/Leaflet/Leaflet/releases/latestDisable redirect follow:FalseChanges only:True
By disabling Disable redirect follow the agent will follow the redirect, and provide the final link in final_url. And by enabling Changes only this agent is only emitting events when something changes - a new version is released.
Formatting the data: Event Formatting Agent
The incoming data from the Http Status Agent looks like this:
| |
What I need is the version information after tag/. The Formatting Agent can do that using the matchers. As source specify the output from the Http Status Agent above. As Options the following
| |
The matchers will extract everything after tag/ using a regexp, and store the information in version. The instructions creates new variables using the data from the match.
Notify: Email Agent
As input use the output from the Event Formatting Agent. I’m using the following options:
| |
This creates a short email, with the new version information included.
Comments
With an account on the Fediverse or Mastodon, you can respond to this post. Known replies are displayed below:
Note: This will load data from mastodon.social.
Learn how this is implemented here.
Share: