commit 6f54f1663f018b556fada3f20f0e9726810af994 Author: Romulus21 Date: Fri Oct 31 21:30:15 2025 +0100 first commit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3b80d15 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +deploy: + zip -r octorpint-get-request.zip ./*.py + #scp ./*.py octoprint:/home/pi/.octoprint/plugins/get-request/ diff --git a/__init__.py b/__init__.py new file mode 100755 index 0000000..f289b55 --- /dev/null +++ b/__init__.py @@ -0,0 +1,31 @@ +from __future__ import absolute_import +import octoprint.plugin +import requests +import logging + +class WebhookOnPrintDone(octoprint.plugin.StartupPlugin, + octoprint.plugin.EventHandlerPlugin): + + def on_after_startup(self): + self._logger.info("WebhookOnPrintDone started!") + + def on_event(self, event, payload): + if event == "PrintDone": + self._logger.info("Print finished, sending webhook request...") + self.send_webhook(payload) + + def send_webhook(self, payload): + url = "https://smsapi.free-mobile.fr/sendmsg?user=58834922&pass=OgGZvJjNf5GCSU&to=0681952587&msg=Impression terminée" # Remplacez par l'URL réelle du webhook + try: + response = requests.get(url) + response.raise_for_status() + self._logger.info(f"Webhook sent successfully: {response.status_code}") + except requests.RequestException as e: + self._logger.error(f"Failed to send webhook: {e}") + +__plugin_name__ = "WebhookOnPrintDone" +__plugin_version__ = "1.0.0" + +def __plugin_load__(): + global __plugin_implementation__ + __plugin_implementation__ = WebhookOnPrintDone() diff --git a/octorpint-get-request.zip b/octorpint-get-request.zip new file mode 100644 index 0000000..789be43 Binary files /dev/null and b/octorpint-get-request.zip differ diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..b16ed55 --- /dev/null +++ b/setup.py @@ -0,0 +1,17 @@ +from setuptools import setup + +setup( + name="OctoPrint-WebhookOnPrintDone", + version="1.0.0", + description="Un plugin OctoPrint qui envoie une requête webhook à la fin d'une impression.", + author="Ton Nom", + author_email="ton.email@example.com", + url="https://github.com/ton-repo", # Mettre un lien vers ton repo si tu en as un + packages=["octoprint_WebhookOnPrintDone"], + install_requires=["requests"], + entry_points={ + "octoprint.plugin": [ + "WebhookOnPrintDone = octoprint_WebhookOnPrintDone" + ] + }, +)