Louis Lam
3 years ago
11 changed files with 175 additions and 62 deletions
@ -0,0 +1,6 @@ |
|||
module.exports = { |
|||
apps: [{ |
|||
name: "uptime-kuma", |
|||
script: "./server/server.js", |
|||
}] |
|||
} |
@ -0,0 +1,83 @@ |
|||
const NotificationProvider = require("./notification-provider"); |
|||
const axios = require("axios"); |
|||
const { DOWN, UP } = require("../../src/util"); |
|||
|
|||
class Feishu extends NotificationProvider { |
|||
name = "Feishu"; |
|||
|
|||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { |
|||
let okMsg = "Sent Successfully."; |
|||
let feishuWebHookUrl = notification.feishuWebHookUrl; |
|||
|
|||
try { |
|||
if (heartbeatJSON == null) { |
|||
let testdata = { |
|||
msg_type: "text", |
|||
content: { |
|||
text: msg, |
|||
}, |
|||
}; |
|||
await axios.post(feishuWebHookUrl, testdata); |
|||
return okMsg; |
|||
} |
|||
|
|||
if (heartbeatJSON["status"] == DOWN) { |
|||
let downdata = { |
|||
msg_type: "post", |
|||
content: { |
|||
post: { |
|||
zh_cn: { |
|||
title: "UptimeKuma Alert: " + monitorJSON["name"], |
|||
content: [ |
|||
[ |
|||
{ |
|||
tag: "text", |
|||
text: |
|||
"[Down] " + |
|||
heartbeatJSON["msg"] + |
|||
"\nTime (UTC): " + |
|||
heartbeatJSON["time"], |
|||
}, |
|||
], |
|||
], |
|||
}, |
|||
}, |
|||
}, |
|||
}; |
|||
await axios.post(feishuWebHookUrl, downdata); |
|||
return okMsg; |
|||
} |
|||
|
|||
if (heartbeatJSON["status"] == UP) { |
|||
let updata = { |
|||
msg_type: "post", |
|||
content: { |
|||
post: { |
|||
zh_cn: { |
|||
title: "UptimeKuma Alert: " + monitorJSON["name"], |
|||
content: [ |
|||
[ |
|||
{ |
|||
tag: "text", |
|||
text: |
|||
"[Up] " + |
|||
heartbeatJSON["msg"] + |
|||
"\nTime (UTC): " + |
|||
heartbeatJSON["time"], |
|||
}, |
|||
], |
|||
], |
|||
}, |
|||
}, |
|||
}, |
|||
}; |
|||
await axios.post(feishuWebHookUrl, updata); |
|||
return okMsg; |
|||
} |
|||
} catch (error) { |
|||
this.throwGeneralAxiosError(error); |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = Feishu; |
@ -0,0 +1,15 @@ |
|||
<template> |
|||
<div class="mb-3"> |
|||
<label for="Feishu-WebHookUrl" class="form-label">{{ $t("Feishu WebHookUrl") }}<span style="color: red;"><sup>*</sup></span></label> |
|||
<input id="Feishu-WebHookUrl" v-model="$parent.notification.feishuWebHookUrl" type="text" class="form-control" required> |
|||
<div class="form-text"> |
|||
<p><span style="color: red;"><sup>*</sup></span>{{ $t("Required") }}</p> |
|||
</div> |
|||
<i18n-t tag="div" keypath="wayToGetTeamsURL" class="form-text"> |
|||
<a |
|||
href="https://www.feishu.cn/hc/zh-CN/articles/360024984973" |
|||
target="_blank" |
|||
>{{ $t("here") }}</a> |
|||
</i18n-t> |
|||
</div> |
|||
</template> |
Loadingโฆ
Reference in new issue