test sendMessage
This commit is contained in:
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.
29
sendMessage.py
Normal file
29
sendMessage.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import octoprint.plugin
|
||||
|
||||
|
||||
class SendMessagePlugin(octoprint.plugin.StartupPlugin):
|
||||
def on_after_startup(self):
|
||||
self._logger.info("Send Message plugin 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}")
|
||||
self._logger.info("payload")
|
||||
self._logger.info(payload)
|
||||
except requests.RequestException as e:
|
||||
self._logger.error(f"Failed to send webhook: {e}")
|
||||
|
||||
|
||||
__plugin_name__ = "Send Message"
|
||||
__plugin_version__ = "1.0.0"
|
||||
__plugin_description__ = "Send SMS on finish work"
|
||||
__plugin_pythoncompat__ = ">=3.7,<4"
|
||||
__plugin_implementation__ = SendMessagePlugin()
|
||||
Reference in New Issue
Block a user