first commit

This commit is contained in:
Romulus21
2025-10-31 21:30:15 +01:00
commit 6f54f1663f
4 changed files with 51 additions and 0 deletions

31
__init__.py Executable file
View File

@@ -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()