From 449ddc266f923d5ee97a55b3bd6ca5f494e4762f Mon Sep 17 00:00:00 2001 From: Waheed-Mousad Date: Mon, 9 Jun 2025 06:17:07 +0300 Subject: [PATCH] add discord notification node --- LICENSE | 21 +++++++++++++++ __init__.py | 5 ++++ __pycache__/__init__.cpython-312.pyc | Bin 391 -> 483 bytes __pycache__/notify_discord.cpython-312.pyc | Bin 0 -> 1760 bytes notify_discord.py | 30 +++++++++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 __pycache__/notify_discord.cpython-312.pyc create mode 100644 notify_discord.py 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 01dd697cdbd98545e8546f772e30973e24d18ecd..f58e9fda77e14c5d8bfb738c55f5e684274f05d1 100644 GIT binary patch delta 248 zcmZo?e#{(mnwOW00SIb++%no285kaeI55BrWqdXOGNv=6Fr+Z%Fyt~uF*1VKOgT)s z%u&pY45^H%%qh%sn4(xxSW;NQEY?akP4i<9$5bZ znTkM07qLvtmy<3P1~Na)pR`5+s!jo_P?K%q1UW&zJg~O-6o?@}J*yVm@&L5}9m`Ox x4bscZ$jEq?!R9W5?gusoMavtKS|3?i#F;KI2!G%M^YwsyIi`yYQbi!Y0syB3JNf_s delta 183 zcmaFN+|KNCnwOW00SMx}+%mob>Bk@r3@||%pA~?N=?p0hDU3M`xr|Yaj0`DEsf?M7 zQA{aJDa=5cxspYbbz+PnQxWsT*>bXenk=`(^72bE(<4BO~Ko2AdCT46O1O6f8b4Gl?@@U=aSm1?S5#U1X3d;s7cJ E0Hk>+l>h($ diff --git a/__pycache__/notify_discord.cpython-312.pyc b/__pycache__/notify_discord.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f0b19f0ac17dac1ab804bbcd70ab0a3e5580a7c3 GIT binary patch literal 1760 zcmaJ>K};J*6rJ_1cWtn-O;VebmTU^NF%`Cywg^boh!A6F!5}cIaGb7|opo5Sz0S_M z#t2uaq7sK*+6#vyDpe~r5jpgjYjbT6OPdO7%OOfnxjAv9w&|raUT@_FrE~cEXa4_h z{`~*`{^<3#0ldDQo>=*d2HO59<0R)iBf)sFoIDn3A0O@^)<&mPwRG4{0 zHVMf(vSiZ^>Jhx(1u{rc5TqP34XJIg-}Fo|(2;UNI>kaJ#X;vbNV&>vm@@;H6eOt{ zOsKk&DJN7YOH>Owi*=kbsK15P3DfnCTzvI>0BilJhvddb{4;( zLwDN-$m}>!eXoO?EqLxGVlU7=wqGC6x+-kT9o!~s zXH9`6JcJeY6V}Sa(o0kctkX-NL=lE_lA71$ypCzctRgl4=qHR^Bt5-c`|8U({IULD z;R)GiEUxkhhw{2=yG4p*wjSR6+&*aZvoVT%Ow&|tl%Gr{=lBhpALNVti+$H6xj+ay zipScCbWJH(vnV4SnM^@Ny4j9&Q7ayFy21`zTQ3bvv1(Y z|B?}$x$jTZJRop#=i?pkQ#S|%jjqwV!-wZ*56;gTqjSdGf{{!gCdGrKXe=xnLFrdN ztht&2e?H}a|I`yexkrvX0i*Nn@5MvUu;Ceg;6FhC|E_V^^bGajWIr7Xj9maf1pA4+ z;J(Py_gtQf-SoX~C)N{Tx9JjuyqJ>(!E6(RoC=FsqI(44T2ah4E$vcPL?|cgD=O3i z7}oU6$C8Wl3G2UMx+WGAL{0UM|ht=0)n_H0d8eW9(%s;_5jvd(y%K?{ZihaK9>_|pJ-?grEKuJwfX dv^TK}nN38luhA4m{RVu0Fx^z}3BaNO_YauU#fbm_ literal 0 HcmV?d00001 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,)