mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
@@ -95,6 +95,10 @@ const push_config = {
|
||||
WEBHOOK_HEADERS: '', // 自定义通知 请求头
|
||||
WEBHOOK_METHOD: '', // 自定义通知 请求方法
|
||||
WEBHOOK_CONTENT_TYPE: '', // 自定义通知 content-type
|
||||
|
||||
NTFY_URL: '', // ntfy地址,如https://ntfy.sh,默认为https://ntfy.sh
|
||||
NTFY_TOPIC: '', // ntfy的消息应用topic
|
||||
NTFY_PRIORITY: '3', // 推送消息优先级,默认为3
|
||||
};
|
||||
|
||||
for (const key in push_config) {
|
||||
@@ -1188,6 +1192,42 @@ function webhookNotify(text, desp) {
|
||||
});
|
||||
}
|
||||
|
||||
function ntfyNotify(text, desp) {
|
||||
return new Promise((resolve) => {
|
||||
const { NTFY_URL, NTFY_TOPIC, NTFY_PRIORITY } = push_config;
|
||||
if (NTFY_TOPIC) {
|
||||
const options = {
|
||||
url: NTFY_URL || `https://ntfy.sh`,
|
||||
body: `${desp}\n${text}`,
|
||||
headers: {
|
||||
'Title': 'qinglong',
|
||||
'Priority': NTFY_PRIORITY || '3'
|
||||
},
|
||||
timeout,
|
||||
};
|
||||
$.post(options, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log('Ntfy 通知调用API失败😞\n', err);
|
||||
} else {
|
||||
if (data.success) {
|
||||
console.log('Ntfy 发送通知消息成功🎉\n');
|
||||
} else {
|
||||
console.log(`Ntfy 发送通知消息异常 ${JSON.stringify(data)}`);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp);
|
||||
} finally {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function parseString(input, valueFormatFn) {
|
||||
const regex = /(\w+):\s*((?:(?!\n\w+:).)*)/g;
|
||||
const matches = {};
|
||||
@@ -1316,6 +1356,7 @@ async function sendNotify(text, desp, params = {}) {
|
||||
chronocatNotify(text, desp), // Chronocat
|
||||
webhookNotify(text, desp), // 自定义通知
|
||||
qmsgNotify(text, desp), // 自定义通知
|
||||
ntfyNotify(text, desp), // Ntfy
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user