Chronocat发送时没有配置群号或个人消息号发送出错

This commit is contained in:
child 2023-10-11 16:08:39 +08:00
parent 2f32452e75
commit bbac6aba4b

View File

@ -1192,6 +1192,7 @@ function PushMeNotify(text, desp, params = {}) {
}
function ChronocatNotify(title, desp) {
return new Promise((resolve) => {
// 检查 CHRONOCAT 的配置是否完整
if (!CHRONOCAT_TOKEN || !CHRONOCAT_QQ || !CHRONOCAT_URL) {
console.log("CHRONOCAT 服务的 CHRONOCAT_URL 或 CHRONOCAT_QQ 未设置!!\n取消推送");
@ -1201,8 +1202,8 @@ function ChronocatNotify(title, desp) {
console.log("CHRONOCAT 服务启动");
// 提取 user_id 和 group_id
const user_ids = CHRONOCAT_QQ.match(/user_id=(\d+)/g).map(match => match.split("=")[1]);
const group_ids = CHRONOCAT_QQ.match(/group_id=(\d+)/g).map(match => match.split("=")[1]);
const user_ids = CHRONOCAT_QQ.match(/user_id=(\d+)/g)?.map(match => match.split("=")[1]);
const group_ids = CHRONOCAT_QQ.match(/group_id=(\d+)/g)?.map(match => match.split("=")[1]);
// 设置请求的 URL 和 Headers
const url = `${CHRONOCAT_URL}/api/message/send`;
@ -1233,7 +1234,7 @@ function ChronocatNotify(title, desp) {
};
const options = {
url: url,
json:JSON.stringify(data),
json: data,
headers,
timeout,
};
@ -1263,9 +1264,11 @@ function ChronocatNotify(title, desp) {
});
}
}
})
}
module.exports = {
sendNotify,
BARK_PUSH,