summaryrefslogtreecommitdiffstats
path: root/server/notification-providers/kook.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/notification-providers/kook.js')
-rw-r--r--server/notification-providers/kook.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/server/notification-providers/kook.js b/server/notification-providers/kook.js
new file mode 100644
index 0000000..dab1951
--- /dev/null
+++ b/server/notification-providers/kook.js
@@ -0,0 +1,34 @@
+const NotificationProvider = require("./notification-provider");
+const axios = require("axios");
+
+class Kook extends NotificationProvider {
+ name = "Kook";
+
+ /**
+ * @inheritdoc
+ */
+ async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
+ const okMsg = "Sent Successfully.";
+ const url = "https://www.kookapp.cn/api/v3/message/create";
+
+ let data = {
+ target_id: notification.kookGuildID,
+ content: msg,
+ };
+ let config = {
+ headers: {
+ "Authorization": "Bot " + notification.kookBotToken,
+ "Content-Type": "application/json",
+ },
+ };
+ try {
+ await axios.post(url, data, config);
+ return okMsg;
+
+ } catch (error) {
+ this.throwGeneralAxiosError(error);
+ }
+ }
+}
+
+module.exports = Kook;