diff --git a/LICENSE b/LICENSE index e69de29..1c7da7f 100644 --- a/LICENSE +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Waheed Mousad + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/__init__.py b/__init__.py index 0312984..2a7b8bc 100644 --- a/__init__.py +++ b/__init__.py @@ -1,9 +1,14 @@ from .notify_whatsapp_twilio import WhatsAppNotifyNodeTwilio +from .notify_discord import DiscordNotifyNode NODE_CLASS_MAPPINGS = { "WhatsAppNotifyNodeTwilio": WhatsAppNotifyNodeTwilio, + "DiscordNotifyNode": DiscordNotifyNode, + } NODE_DISPLAY_NAME_MAPPINGS = { "WhatsAppNotifyNodeTwilio": "📲 WhatsApp (Twilio)", + "DiscordNotifyNode": "💬 Discord Notify", + } \ No newline at end of file diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc index 01dd697..f58e9fd 100644 Binary files a/__pycache__/__init__.cpython-312.pyc and b/__pycache__/__init__.cpython-312.pyc differ diff --git a/__pycache__/notify_discord.cpython-312.pyc b/__pycache__/notify_discord.cpython-312.pyc new file mode 100644 index 0000000..f0b19f0 Binary files /dev/null and b/__pycache__/notify_discord.cpython-312.pyc differ diff --git a/notify_discord.py b/notify_discord.py new file mode 100644 index 0000000..d7b9b42 --- /dev/null +++ b/notify_discord.py @@ -0,0 +1,30 @@ +import requests + +class DiscordNotifyNode: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "img": ("IMAGE",), + "message": ("STRING", {"default": "✅ Workflow complete!"}), + "webhook_url": ("STRING", {"default": "https://discord.com/api/webhooks/..."}), + } + } + + RETURN_TYPES = ("IMAGE",) + FUNCTION = "notify" + CATEGORY = "Notifications" + + def notify(self, img, message, webhook_url): + try: + payload = {"content": message.strip()} + response = requests.post(webhook_url.strip(), json=payload) + + if response.status_code == 204: + print("[💬 DiscordNotifyNode] ✅ Message sent to Discord.") + else: + print(f"❌ DiscordNotifyNode Error: HTTP {response.status_code} - {response.text}") + except Exception as e: + print("❌ DiscordNotifyNode Exception:", e) + + return (img,)