mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-07 20:06:08 +08:00
修复node pushdeer通知
This commit is contained in:
parent
952cdc0e3f
commit
4da8d8fe1e
|
@ -4,7 +4,7 @@ export enum NotificationMode {
|
||||||
'serverChan' = 'serverChan',
|
'serverChan' = 'serverChan',
|
||||||
'pushDeer' = 'pushDeer',
|
'pushDeer' = 'pushDeer',
|
||||||
'bark' = 'bark',
|
'bark' = 'bark',
|
||||||
'chat' = 'chat'
|
'chat' = 'chat',
|
||||||
'telegramBot' = 'telegramBot',
|
'telegramBot' = 'telegramBot',
|
||||||
'dingtalkBot' = 'dingtalkBot',
|
'dingtalkBot' = 'dingtalkBot',
|
||||||
'weWorkBot' = 'weWorkBot',
|
'weWorkBot' = 'weWorkBot',
|
||||||
|
@ -40,7 +40,7 @@ export class PushDeerNotification extends NotificationBaseInfo {
|
||||||
|
|
||||||
export class ChatNotification extends NotificationBaseInfo {
|
export class ChatNotification extends NotificationBaseInfo {
|
||||||
public chatUrl = '';
|
public chatUrl = '';
|
||||||
public chattoken = '';
|
public chatToken = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BarkNotification extends NotificationBaseInfo {
|
export class BarkNotification extends NotificationBaseInfo {
|
||||||
|
|
|
@ -137,8 +137,8 @@ export default class NotificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async chat() {
|
private async chat() {
|
||||||
const { chatUrl, chattoken } = this.params;
|
const { chatUrl, chatToken } = this.params;
|
||||||
const url = `${chatUrl}${chattoken}`;
|
const url = `${chatUrl}${chatToken}`;
|
||||||
const res: any = await got
|
const res: any = await got
|
||||||
.post(url, {
|
.post(url, {
|
||||||
timeout: this.timeout,
|
timeout: this.timeout,
|
||||||
|
@ -147,9 +147,7 @@ export default class NotificationService {
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
})
|
})
|
||||||
.json();
|
.json();
|
||||||
return (
|
return res.success;
|
||||||
res.success
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async bark() {
|
private async bark() {
|
||||||
|
|
|
@ -254,6 +254,7 @@ async function sendNotify(
|
||||||
gobotNotify(text, desp), //go-cqhttp
|
gobotNotify(text, desp), //go-cqhttp
|
||||||
gotifyNotify(text, desp), //gotify
|
gotifyNotify(text, desp), //gotify
|
||||||
ChatNotify(text, desp), //synolog chat
|
ChatNotify(text, desp), //synolog chat
|
||||||
|
PushDeerNotify(text, desp), //PushDeer
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +385,7 @@ function serverNotify(text, desp, time = 2100) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function PushDeerNotify(text, desp, time = 2100) {
|
function PushDeerNotify(text, desp) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (PUSHDEER_KEY) {
|
if (PUSHDEER_KEY) {
|
||||||
// PushDeer 建议对消息内容进行 urlencode
|
// PushDeer 建议对消息内容进行 urlencode
|
||||||
|
@ -397,8 +398,9 @@ function PushDeerNotify(text, desp, time = 2100) {
|
||||||
},
|
},
|
||||||
timeout,
|
timeout,
|
||||||
};
|
};
|
||||||
setTimeout(() => {
|
$.post(
|
||||||
$.post(options, (err, resp, data) => {
|
options,
|
||||||
|
(err, resp, data) => {
|
||||||
try {
|
try {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('发送通知调用API失败!!\n');
|
console.log('发送通知调用API失败!!\n');
|
||||||
|
@ -422,17 +424,18 @@ function PushDeerNotify(text, desp, time = 2100) {
|
||||||
} finally {
|
} finally {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
}, time);
|
time,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ChatNotify(text, desp, time = 2100) {
|
function ChatNotify(text, desp) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (CHAT_URL && CHAT_TOKEN ) {
|
if (CHAT_URL && CHAT_TOKEN) {
|
||||||
// 对消息内容进行 urlencode
|
// 对消息内容进行 urlencode
|
||||||
desp = encodeURI(desp);
|
desp = encodeURI(desp);
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -442,31 +445,25 @@ function ChatNotify(text, desp, time = 2100) {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setTimeout(() => {
|
$.post(options, (err, resp, data) => {
|
||||||
$.post(options, (err, resp, data) => {
|
try {
|
||||||
try {
|
if (err) {
|
||||||
if (err) {
|
console.log('发送通知调用API失败!!\n');
|
||||||
console.log('发送通知调用API失败!!\n');
|
console.log(err);
|
||||||
console.log(err);
|
} else {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data.success) {
|
||||||
|
console.log('Chat发送通知消息成功🎉\n');
|
||||||
} else {
|
} else {
|
||||||
data = JSON.parse(data);
|
console.log(`Chat发送通知消息异常\n${JSON.stringify(data)}`);
|
||||||
if (
|
|
||||||
data.success
|
|
||||||
) {
|
|
||||||
console.log('Chat发送通知消息成功🎉\n');
|
|
||||||
} else {
|
|
||||||
console.log(
|
|
||||||
`Chat发送通知消息异常\n${JSON.stringify(data)}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
$.logErr(e);
|
|
||||||
} finally {
|
|
||||||
resolve(data);
|
|
||||||
}
|
}
|
||||||
});
|
} catch (e) {
|
||||||
}, time);
|
$.logErr(e);
|
||||||
|
} finally {
|
||||||
|
resolve(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ export default {
|
||||||
{ value: 'weWorkApp', label: '企业微信应用' },
|
{ value: 'weWorkApp', label: '企业微信应用' },
|
||||||
{ value: 'iGot', label: 'IGot' },
|
{ value: 'iGot', label: 'IGot' },
|
||||||
{ value: 'pushPlus', label: 'PushPlus' },
|
{ value: 'pushPlus', label: 'PushPlus' },
|
||||||
{ value: 'chat', label: 'chat' },
|
{ value: 'chat', label: '群辉chat' },
|
||||||
{ value: 'email', label: '邮箱' },
|
{ value: 'email', label: '邮箱' },
|
||||||
{ value: 'closed', label: '已关闭' },
|
{ value: 'closed', label: '已关闭' },
|
||||||
],
|
],
|
||||||
|
@ -110,7 +110,7 @@ export default {
|
||||||
tip: 'chat的url地址',
|
tip: 'chat的url地址',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{ label: 'chattoken', tip: 'chat的token码', required: true },
|
{ label: 'chatToken', tip: 'chat的token码', required: true },
|
||||||
],
|
],
|
||||||
goCqHttpBot: [
|
goCqHttpBot: [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user