From 98a558cf5625cb8293f4f0c5afa5d08782b67b0f Mon Sep 17 00:00:00 2001 From: phit Date: Fri, 21 Jul 2017 02:08:59 +0200 Subject: [PATCH 1/2] added Discord support --- README.md | 3 +++ push.cpp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/README.md b/README.md index 1fdf44e..53c0a01 100755 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ conditions. ZNC Push current supports the following services: * [Pushjet][] * [Telegram][] * [Slack][] +* [Discord][] * Custom URL GET requests This project is still a Work In Progress, but should be functional enough and stable enough @@ -252,6 +253,7 @@ to something similar to "http://domain/#channel/2011-03-09 14:25:09", or * `pushjet` * `telegram` * `slack` + * `discord` * `url` * `username` Default: ` ` @@ -539,6 +541,7 @@ from me and not from my employer. See the `LICENSE` file for details. [Pushjet]: http://pushjet.io [Telegram]: https://telegram.org/ [Slack]: https://slack.com/ +[Discord]: https://discord.gg [faq]: https://github.com/jreese/znc-push/blob/master/doc/faq.md [examples]: https://github.com/jreese/znc-push/blob/master/doc/examples.md diff --git a/push.cpp b/push.cpp index 31a7892..abdec80 100755 --- a/push.cpp +++ b/push.cpp @@ -671,6 +671,25 @@ class CPushMod : public CModule PutDebug("payload: " + params["payload"]); } + else if (service == "discord") + { + if (options["secret"] == "") + { + PutModule("Error: target (from webhook, e.g. 111111111111111111/abcdefghijklmopqrstuvwxyz1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ123456) not set"); + return; + } + + service_host = "discordapp.com"; + service_url = "/api/webhooks/" + options["secret"]; + + if (options["username"] != "") + { + params["username"] = options["username"]; + } + + params["content"] = message_content; + + } else if (service == "pushjet") { if (options["secret"] == "") @@ -1444,6 +1463,10 @@ class CPushMod : public CModule { PutModule("Note: Slack requires setting 'secret' (from webhook) and 'target' (channel or username), optional 'username' (bot name)"); } + else if (value == "discord") + { + PutModule("Note: Discord requires setting 'secret' (from webhook), optional 'username' (bot name)"); + } else if (value == "pushjet") { PutModule("Note: Pushjet requires setting 'secret' (service key) option"); From f79e8ea8fba7a2f1ba97242269f0321e4f8e1a0d Mon Sep 17 00:00:00 2001 From: phit Date: Fri, 21 Jul 2017 02:13:49 +0200 Subject: [PATCH 2/2] small typo --- push.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/push.cpp b/push.cpp index abdec80..15c6b0d 100755 --- a/push.cpp +++ b/push.cpp @@ -675,7 +675,7 @@ class CPushMod : public CModule { if (options["secret"] == "") { - PutModule("Error: target (from webhook, e.g. 111111111111111111/abcdefghijklmopqrstuvwxyz1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ123456) not set"); + PutModule("Error: secret (from webhook, e.g. 111111111111111111/abcdefghijklmopqrstuvwxyz1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ123456) not set"); return; }