user notifications
This commit is contained in:
parent
dd86b82e1c
commit
f8e47879f1
@ -5,5 +5,6 @@
|
||||
"device_model": "",
|
||||
"device_id": "",
|
||||
"sys_version": "",
|
||||
"channel": ""
|
||||
"channel": "",
|
||||
"email": ""
|
||||
}
|
||||
|
@ -164,3 +164,20 @@ exports.SendLog = function (
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
exports.SendResult = function (transporter, mailfrom, mailto, content) {
|
||||
transporter.sendMail(
|
||||
{
|
||||
from: `"Genshin Cloud Game Helper" <${mailfrom}>`, //邮件来源
|
||||
to: mailto, //邮件发送到哪里,多个邮箱使用逗号隔开
|
||||
subject: `Genshin Cloud Game Helper`, // 邮件主题
|
||||
text: `${content}`, // 存文本类型的邮件正文
|
||||
},
|
||||
(error) => {
|
||||
if (error) {
|
||||
return console.log(error);
|
||||
}
|
||||
log.info(`已发送通知至${mailto}`);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
17
src/index.js
17
src/index.js
@ -8,6 +8,7 @@ const {
|
||||
SendLog,
|
||||
AppVersion,
|
||||
getGlobalConfig,
|
||||
SendResult,
|
||||
} = require("./config");
|
||||
|
||||
const { log, addLogContent, getLogs, sleep } = require("./util");
|
||||
@ -64,6 +65,14 @@ const nodemailer = require("nodemailer");
|
||||
log.info(
|
||||
`签到完毕! 获得时长:${WalletRespond.data.free_time.send_freetime}分钟,总时长:${WalletRespond.data.free_time.free_time}分钟`
|
||||
);
|
||||
if (configs[key].email != null) {
|
||||
SendResult(
|
||||
transporter,
|
||||
globalConfig.mailConfig.user,
|
||||
configs[key].email,
|
||||
`签到完毕! 获得时长:${WalletRespond.data.free_time.send_freetime}分钟,总时长:${WalletRespond.data.free_time.free_time}分钟`
|
||||
);
|
||||
}
|
||||
let NotificationLength = NotificationRespond.data.list.length;
|
||||
let postHeader = header;
|
||||
Object.assign(postHeader, {
|
||||
@ -78,6 +87,14 @@ const nodemailer = require("nodemailer");
|
||||
}
|
||||
} else {
|
||||
log.error("签到失败");
|
||||
if (configs[key].email != null) {
|
||||
SendResult(
|
||||
transporter,
|
||||
globalConfig.mailConfig.user,
|
||||
configs[key].email,
|
||||
"签到失败"
|
||||
);
|
||||
}
|
||||
}
|
||||
var delay = Math.round(
|
||||
Math.random() * (maxDelay - minDelay) + minDelay
|
||||
|
Loading…
x
Reference in New Issue
Block a user