fieldOfView / OctoPrint-ngrok

An OctoPrint Plugin that provides remote access using ngrok
GNU Affero General Public License v3.0
15 stars 8 forks source link

Optionally run a script after tunnel opened? #14

Closed derekantrican closed 3 years ago

derekantrican commented 3 years ago

I have a ngrok free plan which means that every time a tunnel is created the url is randomized. Instead of paying for a ngrok plan, I'd like to write a script to do something with assigned ngrok tunnel url (eg email it to myself, use an API to set it as a url redirect with my personal domain, etc).

Simply - could there be an option added to launch a script (with the newly generated ngrok tunnel url as an argument) once the ngrok tunnel has been created?

fieldOfView commented 3 years ago

See https://github.com/fieldOfView/OctoPrint-ngrok/issues/7. The plugin fires the plugin_ngrok_connected event when the plugin creates a tunnel, and the plugin_ngrok_closed event when a tunnel is closed. Both events have the tunnel address as the payload. You could use IFTTT to send emails, or another plugin that responds to plugin events..

derekantrican commented 3 years ago

Ok, I will look into the IFTTT plugin. Thanks!

derekantrican commented 3 years ago

Ok, I've got the IFTTT plugin installed and successfully triggering off the plugin_ngrok_connected event. What should I put in for "Value1", etc to also pass the tunnel url as a parameter?

image

derekantrican commented 3 years ago

Looking at the Value syntax for the IFTTT plugin it seems that it is expecting JSON/dict for the event payload but the ngrok plugin is only sending the single value of the tunnel url. I can start a PR suggesting this change

derekantrican commented 3 years ago

Closing with the merge of #16

fieldOfView commented 3 years ago

I reopened the issue, so I can keep track of changes. I'll soon release version 0.3.0 (in testing now in the devel branch)