Add SpugPush notification provider

This commit is contained in:
vapao 2025-04-30 18:11:00 +08:00
parent 8396330552
commit 0b1308bb02
8 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,48 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class SpugPush extends NotificationProvider {
name = "SpugPush";
/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
try {
await axios.post(`https://push.spug.cc/send/${notification.templateKey}`, {
"status": heartbeatJSON["status"],
"msg": heartbeatJSON["msg"],
"duration": heartbeatJSON["duration"],
"name": monitorJSON["name"],
"target": this.getTarget(monitorJSON),
});
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
/**
* Get the formatted target for message
* @param {object} monitorJSON Monitor details (For Up/Down only)
* @returns {string} Formatted target
*/
getTarget(monitorJSON) {
let target = "-";
if (monitorJSON["hostname"]) {
target = monitorJSON["hostname"];
if (monitorJSON["port"]) {
target += ":" + monitorJSON["port"];
}
} else if (monitorJSON["url"]) {
target = monitorJSON["url"];
}
return target;
}
}
module.exports = SpugPush;

View file

@ -75,6 +75,7 @@ const Wpush = require("./notification-providers/wpush");
const SendGrid = require("./notification-providers/send-grid");
const YZJ = require("./notification-providers/yzj");
const SMSPlanet = require("./notification-providers/sms-planet");
const SpugPush = require("./notification-providers/spugpush");
class Notification {
@ -167,6 +168,7 @@ class Notification {
new SendGrid(),
new YZJ(),
new SMSPlanet(),
new SpugPush(),
];
for (let item of list) {
if (! item.name) {

View file

@ -185,6 +185,7 @@ export default {
"WeCom": "WeCom (企业微信群机器人)",
"ServerChan": "ServerChan (Server酱)",
"PushPlus": "PushPlus (推送加)",
"SpugPush": "SpugPushSpug推送助手",
"smsc": "SMSC",
"WPush": "WPush(wpush.cn)",
"YZJ": "YZJ (云之家自定义机器人)",

View file

@ -0,0 +1,19 @@
<template>
<div class="mb-3">
<label for="spugpush-templateKey" class="form-label">{{ $t("SpugPush Template Key") }}</label>
<HiddenInput id="spugpush-templateKey" v-model="$parent.notification.templateKey" :required="true" autocomplete="new-password"></HiddenInput>
</div>
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;">
<a href="https://push.spug.cc/guide/plugin/kuma" rel="noopener noreferrer" target="_blank">https://push.spug.cc</a>
</i18n-t>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput,
},
};
</script>

View file

@ -64,6 +64,7 @@ import WeCom from "./WeCom.vue";
import GoAlert from "./GoAlert.vue";
import ZohoCliq from "./ZohoCliq.vue";
import Splunk from "./Splunk.vue";
import SpugPush from "./SpugPush.vue";
import SevenIO from "./SevenIO.vue";
import Whapi from "./Whapi.vue";
import WAHA from "./WAHA.vue";
@ -140,6 +141,7 @@ const NotificationFormList = {
"threema": Threema,
"twilio": Twilio,
"Splunk": Splunk,
"SpugPush": SpugPush,
"webhook": Webhook,
"WeCom": WeCom,
"GoAlert": GoAlert,

View file

@ -824,6 +824,7 @@
"Enable Kafka Producer Auto Topic Creation": "启用 Kafka 生成者Producer自动创建主题Topic功能",
"Enable Kafka SSL": "启用 Kafka SSL 功能",
"Kafka Producer Message": "Kafka 生成者Producer消息",
"SpugPush Template Key": "模板编码",
"tailscalePingWarning": "如需使用 Tailscale Ping 客户端,您需要以非 docker 方式安装 Uptime Kuma并同时安装 Tailscale 客户端。",
"Server URL should not contain the nfty topic": "服务器地址不应包含 ntfy主题",
"Select": "选择",

View file

@ -1076,6 +1076,7 @@
"Conditions": "條件",
"Kafka Topic Name": "Kafka 主題名稱",
"Kafka Producer Message": "Kafka 生成者Producer消息",
"SpugPush Template Key": "模板編碼",
"Mechanism": "鑒權方式",
"toastSuccessTimeout": "成功類彈窗通知的自動關閉用時",
"pushoverMessageTtl": "消息存活時間(秒)",

View file

@ -821,6 +821,7 @@
"Enable Kafka SSL": "啟用 Kafka SSL",
"Enable Kafka Producer Auto Topic Creation": "啟用 Kafka Producer 自動主題建立",
"Kafka SASL Options": "Kafka SASL 選項",
"SpugPush Template Key": "模板編碼",
"Mechanism": "機制",
"gamedigGuessPortDescription": "Valve 伺服器查詢協定使用的連接埠可能與客戶端連接埠不同。如果監控無法連線到您的伺服器,請嘗試此選項。",
"Saved.": "已儲存。",