修复小bug

This commit is contained in:
lxk0301
2020-11-10 14:51:34 +08:00
parent 418c85c4fb
commit baa0a1adc4

View File

@@ -74,6 +74,7 @@ if (process.env.IGOT_PUSH_KEY) {
async function sendNotify(text, desp, params = {}) { async function sendNotify(text, desp, params = {}) {
//提供五种通知 //提供五种通知
await serverNotify(text, desp); await serverNotify(text, desp);
text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text;
await BarkNotify(text, desp, params); await BarkNotify(text, desp, params);
await tgBotNotify(text, desp); await tgBotNotify(text, desp);
await ddBotNotify(text, desp); await ddBotNotify(text, desp);
@@ -122,7 +123,7 @@ function BarkNotify(text, desp, params={}) {
return new Promise(resolve => { return new Promise(resolve => {
if (BARK_PUSH) { if (BARK_PUSH) {
const options = { const options = {
url: `${BARK_PUSH}/${encodeURIComponent(text.match(/.*?(?=\s?-)/g) && text.match(/.*?(?=\s?-)/g)[0])}/${encodeURIComponent(desp)}?sound=${BARK_SOUND}&${querystring.stringify(params)}`, url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent(desp)}?sound=${BARK_SOUND}&${querystring.stringify(params)}`,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
} }
@@ -158,7 +159,7 @@ function tgBotNotify(text, desp) {
if (TG_BOT_TOKEN && TG_USER_ID) { if (TG_BOT_TOKEN && TG_USER_ID) {
const options = { const options = {
url: `https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMessage`, url: `https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMessage`,
body: `chat_id=${TG_USER_ID}&text=${text.match(/.*?(?=\s?-)/g) && text.match(/.*?(?=\s?-)/g)[0]}\n\n${desp}&disable_web_page_preview=true`, body: `chat_id=${TG_USER_ID}&text=${text}\n\n${desp}&disable_web_page_preview=true`,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
} }
@@ -209,7 +210,7 @@ function ddBotNotify(text, desp) {
json: { json: {
"msgtype": "text", "msgtype": "text",
"text": { "text": {
"content": ` ${text.match(/.*?(?=\s?-)/g) && text.match(/.*?(?=\s?-)/g)[0]}\n\n${desp}` "content": ` ${text}\n\n${desp}`
} }
}, },
headers: { headers: {
@@ -278,10 +279,10 @@ function iGotNotify(text, desp, params={}){
console.log('\n您所提供的IGOT_PUSH_KEY无效\n') console.log('\n您所提供的IGOT_PUSH_KEY无效\n')
resolve() resolve()
return return
} }
const options = { const options = {
url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`, url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`,
body: `title=${text.match(/.*?(?=\s?-)/g) && text.match(/.*?(?=\s?-)/g)[0]}&content=${desp}&${querystring.stringify(params)}`, body: `title=${text}&content=${desp}&${querystring.stringify(params)}`,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
} }