2022-12-27 01:05:45 -05:00
|
|
|
const NotificationProvider = require("./notification-provider");
|
|
|
|
const axios = require("axios");
|
|
|
|
|
|
|
|
class Kook extends NotificationProvider {
|
|
|
|
name = "Kook";
|
|
|
|
|
2023-08-11 03:46:41 -04:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2022-12-27 01:05:45 -05:00
|
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
2024-03-14 09:21:15 -04:00
|
|
|
const okMsg = "Sent Successfully.";
|
|
|
|
const url = "https://www.kookapp.cn/api/v3/message/create";
|
|
|
|
|
2022-12-27 01:05:45 -05:00
|
|
|
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;
|