Compare commits
2 Commits
6f54f1663f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d8af75cb2 | ||
|
|
4d428b2aa1 |
4
Makefile
4
Makefile
@@ -1,3 +1,3 @@
|
||||
deploy:
|
||||
zip -r octorpint-get-request.zip ./*.py
|
||||
#scp ./*.py octoprint:/home/pi/.octoprint/plugins/get-request/
|
||||
#zip -r octorpint-get-request.zip ./*.py
|
||||
scp sendMessage.py octoprint:/home/pi/.octoprint/plugins/
|
||||
|
||||
Binary file not shown.
24
__init__.py → sendMessage.py
Executable file → Normal file
24
__init__.py → sendMessage.py
Executable file → Normal file
@@ -1,13 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
import octoprint.plugin
|
||||
import requests
|
||||
import logging
|
||||
|
||||
class WebhookOnPrintDone(octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.EventHandlerPlugin):
|
||||
|
||||
class SendMessagePlugin(
|
||||
octoprint.plugin.StartupPlugin, octoprint.plugin.EventHandlerPlugin
|
||||
):
|
||||
def on_after_startup(self):
|
||||
self._logger.info("WebhookOnPrintDone started!")
|
||||
self._logger.info("Send Message plugin started!")
|
||||
|
||||
def on_event(self, event, payload):
|
||||
if event == "PrintDone":
|
||||
@@ -15,17 +14,18 @@ class WebhookOnPrintDone(octoprint.plugin.StartupPlugin,
|
||||
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
|
||||
url = "https://smsapi.free-mobile.fr/sendmsg?user=58834922&pass=OgGZvJjNf5GCSU&to=0681952587&msg=" # Remplacez par l'URL réelle du webhook
|
||||
message = "Impression terminée : " + payload.name
|
||||
try:
|
||||
response = requests.get(url)
|
||||
response = requests.get(url + message)
|
||||
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()
|
||||
__plugin_name__ = "Send Message"
|
||||
__plugin_version__ = "1.0.0"
|
||||
__plugin_description__ = "Send SMS on finish work"
|
||||
__plugin_pythoncompat__ = ">=3.7,<4"
|
||||
__plugin_implementation__ = SendMessagePlugin()
|
||||
17
setup.py
17
setup.py
@@ -1,17 +0,0 @@
|
||||
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"
|
||||
]
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user