diff --git a/server/notification-providers/onebot.js b/server/notification-providers/onebot.js new file mode 100644 index 000000000..c08cc01e8 --- /dev/null +++ b/server/notification-providers/onebot.js @@ -0,0 +1,45 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class OneBot extends NotificationProvider { + + name = "OneBot"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + try { + let httpAddr = notification.httpAddr; + if (!httpAddr.startsWith("http")) { + httpAddr = "http://" + httpAddr; + } + if (!httpAddr.endsWith("/")) { + httpAddr += "/"; + } + let onebotAPIUrl = httpAddr + "send_msg"; + let config = { + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notification.accessToken, + } + }; + let pushText = "UptimeKuma Alert: " + msg; + let data = { + "auto_escape": true, + "message": pushText, + }; + if (notification.msgType == "group") { + data["message_type"] = "group"; + data["group_id"] = notification.recieverId; + } else { + data["message_type"] = "private"; + data["user_id"] = notification.recieverId; + } + await axios.post(onebotAPIUrl, data, config); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = OneBot; diff --git a/server/notification-providers/pushdeer.js b/server/notification-providers/pushdeer.js new file mode 100644 index 000000000..620c1b20a --- /dev/null +++ b/server/notification-providers/pushdeer.js @@ -0,0 +1,52 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const { DOWN, UP } = require("../../src/util"); + +class PushDeer extends NotificationProvider { + + name = "PushDeer"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + let pushdeerlink = "https://api2.pushdeer.com/message/push"; + + let valid = msg != null && monitorJSON != null && heartbeatJSON != null; + + let title; + if (valid && heartbeatJSON.status == UP) { + title = "## Uptime Kuma: " + monitorJSON.name + " up"; + } else if (valid && heartbeatJSON.status == DOWN) { + title = "## Uptime Kuma: " + monitorJSON.name + " down"; + } else { + title = "## Uptime Kuma Message"; + } + + let data = { + "pushkey": notification.pushdeerKey, + "text": title, + "desp": msg.replace(/\n/g, "\n\n"), + "type": "markdown", + }; + + try { + let res = await axios.post(pushdeerlink, data); + + if ("error" in res.data) { + let error = res.data.error; + this.throwGeneralAxiosError(error); + } + if (res.data.content.result.length === 0) { + let error = "Invalid PushDeer key"; + this.throwGeneralAxiosError(error); + } else if (JSON.parse(res.data.content.result[0]).success != "ok") { + let error = "Unknown error"; + this.throwGeneralAxiosError(error); + } + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = PushDeer; diff --git a/server/notification.js b/server/notification.js index 359e4c9ec..842e0e2f8 100644 --- a/server/notification.js +++ b/server/notification.js @@ -31,6 +31,8 @@ const WeCom = require("./notification-providers/wecom"); const GoogleChat = require("./notification-providers/google-chat"); const Gorush = require("./notification-providers/gorush"); const Alerta = require("./notification-providers/alerta"); +const OneBot = require("./notification-providers/onebot"); +const PushDeer = require("./notification-providers/pushdeer"); class Notification { @@ -73,6 +75,8 @@ class Notification { new GoogleChat(), new Gorush(), new Alerta(), + new OneBot(), + new PushDeer(), ]; for (let item of list) { diff --git a/server/server.js b/server/server.js index 109221e2d..ced5626c8 100644 --- a/server/server.js +++ b/server/server.js @@ -1228,7 +1228,7 @@ try { } // Only starts importing if the backup file contains at least one proxy - if (proxyListData.length >= 1) { + if (proxyListData && proxyListData.length >= 1) { const proxies = await R.findAll("proxy"); // Loop over proxy list and save proxies diff --git a/src/components/PingChart.vue b/src/components/PingChart.vue index 50d510422..4ff4c708f 100644 --- a/src/components/PingChart.vue +++ b/src/components/PingChart.vue @@ -286,6 +286,7 @@ export default { .dark &:hover { background: $dark-font-color; + color: $dark-font-color2; } } diff --git a/src/components/notifications/OneBot.vue b/src/components/notifications/OneBot.vue new file mode 100644 index 000000000..63604d60f --- /dev/null +++ b/src/components/notifications/OneBot.vue @@ -0,0 +1,34 @@ + diff --git a/src/components/notifications/PushDeer.vue b/src/components/notifications/PushDeer.vue new file mode 100644 index 000000000..c2b7f5cb0 --- /dev/null +++ b/src/components/notifications/PushDeer.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 455b82622..496d35fa0 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -29,6 +29,8 @@ import WeCom from "./WeCom.vue"; import GoogleChat from "./GoogleChat.vue"; import Gorush from "./Gorush.vue"; import Alerta from "./Alerta.vue"; +import OneBot from "./OneBot.vue"; +import PushDeer from "./PushDeer.vue"; /** * Manage all notification form. @@ -67,6 +69,8 @@ const NotificationFormList = { "GoogleChat": GoogleChat, "gorush": Gorush, "alerta": Alerta, + "OneBot": OneBot, + "PushDeer": PushDeer, }; export default NotificationFormList; diff --git a/src/languages/en.js b/src/languages/en.js index ac432ba9a..0ba98e11c 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -445,4 +445,11 @@ export default { "Domain Name Expiry Notification": "Domain Name Expiry Notification", "Proxy": "Proxy", "Date Created": "Date Created", + onebotHttpAddress: "OneBot HTTP Address", + onebotMessageType: "OneBot Message Type", + onebotGroupMessage: "Group", + onebotPrivateMessage: "Private", + onebotUserOrGroupId: "Group/User ID", + onebotSafetyTips: "For safety, must set access token", + "PushDeer Key": "PushDeer Key", }; diff --git a/src/languages/ru-RU.js b/src/languages/ru-RU.js index c8212442b..5e889e52d 100644 --- a/src/languages/ru-RU.js +++ b/src/languages/ru-RU.js @@ -374,8 +374,8 @@ export default { serwersmsSenderName: "SMS Имя Отправителя (регистрированный через пользовательский портал)", stackfield: "Stackfield", smtpDkimSettings: "DKIM Настройки", - smtpDkimDesc: "Please refer to the Nodemailer DKIM {0} for usage.", - documentation: "документация", + smtpDkimDesc: "Пожалуйста ознакомьтесь с {0} Nodemailer DKIM для использования.", + documentation: "документацией", smtpDkimDomain: "Имя Домена", smtpDkimKeySelector: "Ключ", smtpDkimPrivateKey: "Приватный ключ", @@ -389,4 +389,12 @@ export default { alertaApiKey: "Ключ API", alertaAlertState: "Состояние алерта", alertaRecoverState: "Состояние восстановления", + Proxies: "Прокси", + default: "По умолчанию", + enabled: "Включено", + setAsDefault: "Установлено по умолчанию", + deleteProxyMsg: "Вы действительно хотите удалить этот прокси для всех мониторов?", + proxyDescription: "Прокси должны быть привязаны к монитору, чтобы работать.", + enableProxyDescription: "Этот прокси не будет влиять на запросы монитора, пока не будет активирован. Вы можете контролировать временное отключение прокси для всех мониторов через статус активации.", + setAsDefaultProxyDescription: "Этот прокси будет по умолчанию включен для новых мониторов. Вы всё ещё можете отдельно отключать прокси в каждом мониторе.", }; diff --git a/src/languages/zh-CN.js b/src/languages/zh-CN.js index ba1132a3c..2f2d9f2b4 100644 --- a/src/languages/zh-CN.js +++ b/src/languages/zh-CN.js @@ -452,4 +452,10 @@ export default { "Domain Name Expiry Notification": "域名到期时通知", "Proxy": "代理", "Date Created": "创建于", + onebotHttpAddress: "OneBot HTTP 地址", + onebotMessageType: "OneBot 消息类型", + onebotGroupMessage: "群聊", + onebotPrivateMessage: "私聊", + onebotUserOrGroupId: "群组/用户ID", + onebotSafetyTips: "出于安全原因,请务必设置AccessToken", };