summaryrefslogtreecommitdiffstats
path: root/server/notification-providers/kook.js
blob: dab19513a914bfb3cab9dcee59f18d9479c858db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;