add name to message and clean unused code
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import octoprint.plugin
|
||||
import requests
|
||||
|
||||
|
||||
class SendMessagePlugin(octoprint.plugin.StartupPlugin):
|
||||
class SendMessagePlugin(
|
||||
octoprint.plugin.StartupPlugin, octoprint.plugin.EventHandlerPlugin
|
||||
):
|
||||
def on_after_startup(self):
|
||||
self._logger.info("Send Message plugin started!")
|
||||
|
||||
@@ -11,13 +14,12 @@ class SendMessagePlugin(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}")
|
||||
self._logger.info("payload")
|
||||
self._logger.info(payload)
|
||||
except requests.RequestException as e:
|
||||
self._logger.error(f"Failed to send webhook: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user