mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
feat: 添加Gotify推送
This commit is contained in:
parent
201770573e
commit
69c297ecaa
@ -92,6 +92,8 @@ module.exports = Object.freeze({
|
||||
SMTP_PORT: "",
|
||||
SMTP_USER: "",
|
||||
SMTP_PASS: "",
|
||||
SMTP_TO_USER: ""
|
||||
SMTP_TO_USER: "",
|
||||
GOTIFY_URL: "",
|
||||
GOTIFY_APPKEY: ""
|
||||
}
|
||||
})
|
||||
@ -80,6 +80,13 @@ let SMTP_USER = '';
|
||||
let SMTP_PASS = '';
|
||||
let SMTP_TO_USER = '';
|
||||
|
||||
// ====================================Gotify======================================
|
||||
// 官方文档:https://gotify.net/docs/pushmsg
|
||||
// 此处填你的Gotify消息推送地址(例如:http://localhost/message)
|
||||
let GOTIFY_URL = '';
|
||||
// 此处填你想推送的Application的Token(不包含推送时额外添加的前缀 Bearer )
|
||||
let GOTIFY_APPKEY = '';
|
||||
|
||||
//==========================云端环境变量的判断与接收=========================
|
||||
if (process.env.SCKEY) {
|
||||
SCKEY = process.env.SCKEY;
|
||||
@ -190,6 +197,13 @@ if (process.env.SMTP_TO_USER) {
|
||||
SMTP_TO_USER = process.env.SMTP_TO_USER;
|
||||
}
|
||||
|
||||
if (process.env.GOTIFY_URL) {
|
||||
GOTIFY_URL = process.env.GOTIFY_URL;
|
||||
if (process.env.GOTIFY_APPKEY) {
|
||||
GOTIFY_APPKEY = process.env.GOTIFY_APPKEY
|
||||
}
|
||||
}
|
||||
|
||||
//==========================云端环境变量的判断与接收=========================
|
||||
|
||||
async function sendNotify(text, desp, params = {}) {
|
||||
@ -223,7 +237,9 @@ async function sendNotify(text, desp, params = {}) {
|
||||
// Qmsg
|
||||
qmsg(text, desp),
|
||||
//电子邮件
|
||||
email(text, desp)
|
||||
email(text, desp),
|
||||
// Gotify
|
||||
gotifyNotify(text, desp)
|
||||
])
|
||||
}
|
||||
|
||||
@ -820,6 +836,41 @@ function pushPlusNotify(text, desp) {
|
||||
})
|
||||
}
|
||||
|
||||
function gotifyNotify(test, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (GOTIFY_APPKEY) {
|
||||
send({
|
||||
method: 'POST',
|
||||
url: GOTIFY_URL,
|
||||
contents: {
|
||||
title: test,
|
||||
message: desp,
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
headers: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + GOTIFY_APPKEY
|
||||
},
|
||||
success: () => {
|
||||
// HTTP 响应码 200 就说明成功了
|
||||
log.info('发送通知', 'Gotify 发送通知消息成功')
|
||||
resolve();
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'Gotify 发送通知调用API失败!!' + err)
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.debug('发送通知', '您未提供Gotify推送所需的GOTIFY_APPKEY,取消Gotify推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function qmsg(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (QMSG_KEY) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user