added Discord support

This commit is contained in:
phit 2017-07-21 02:08:59 +02:00
parent ad20898554
commit 98a558cf56
No known key found for this signature in database
GPG Key ID: 48F84F35867B8C9D
2 changed files with 26 additions and 0 deletions

View File

@ -25,6 +25,7 @@ conditions. ZNC Push current supports the following services:
* [Pushjet][] * [Pushjet][]
* [Telegram][] * [Telegram][]
* [Slack][] * [Slack][]
* [Discord][]
* Custom URL GET requests * Custom URL GET requests
This project is still a Work In Progress, but should be functional enough and stable enough 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` * `pushjet`
* `telegram` * `telegram`
* `slack` * `slack`
* `discord`
* `url` * `url`
* `username` Default: ` ` * `username` Default: ` `
@ -539,6 +541,7 @@ from me and not from my employer. See the `LICENSE` file for details.
[Pushjet]: http://pushjet.io [Pushjet]: http://pushjet.io
[Telegram]: https://telegram.org/ [Telegram]: https://telegram.org/
[Slack]: https://slack.com/ [Slack]: https://slack.com/
[Discord]: https://discord.gg
[faq]: https://github.com/jreese/znc-push/blob/master/doc/faq.md [faq]: https://github.com/jreese/znc-push/blob/master/doc/faq.md
[examples]: https://github.com/jreese/znc-push/blob/master/doc/examples.md [examples]: https://github.com/jreese/znc-push/blob/master/doc/examples.md

View File

@ -671,6 +671,25 @@ class CPushMod : public CModule
PutDebug("payload: " + params["payload"]); 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") else if (service == "pushjet")
{ {
if (options["secret"] == "") 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)"); 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") else if (value == "pushjet")
{ {
PutModule("Note: Pushjet requires setting 'secret' (service key) option"); PutModule("Note: Pushjet requires setting 'secret' (service key) option");