From 2e0cf53937f120be75d13f245a85de8e043d0762 Mon Sep 17 00:00:00 2001 From: jhartworks Date: Tue, 8 Jul 2025 15:09:57 +0200 Subject: [PATCH] added raw message --- Discord Message/module.php | 37 +++++++++++++++++++++++++++++++++++++ library.json | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Discord Message/module.php b/Discord Message/module.php index 0746ef6..5d368c2 100644 --- a/Discord Message/module.php +++ b/Discord Message/module.php @@ -62,6 +62,43 @@ class DiscordMessage extends IPSModule { ///echo "Webhook Response: " . $response; + } + public function SendMessageRaw($data) { + + // Discord webhook URL + $webhookUrl = $this->ReadPropertyString("DiscordWsUrl"); + + // Encode the data as JSON + $jsonData = json_encode($data); + + // Initialize cURL session + $ch = curl_init($webhookUrl); + + // Set cURL options + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + "Content-Type: application/json", + "Content-Length: " . strlen($jsonData) + )); + + // Execute the cURL session and capture the response + $response = curl_exec($ch); + + // Check for cURL errors + if (curl_errno($ch)) { + echo "cURL Error: " . curl_error($ch); + } + + // Close cURL session + curl_close($ch); + + // Display the response from the webhook + ///echo "Webhook Response: " . $response; + + } } + ?> \ No newline at end of file diff --git a/library.json b/library.json index df4b7a4..a52879d 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "version": "6.0", "date": 1491343200 }, - "version": "1.0", + "version": "1.1", "build": 1, "date": 0 } \ No newline at end of file