Support Zenless Zone Zero
This commit is contained in:
168
src/index.js
168
src/index.js
@ -1,12 +1,18 @@
|
||||
const {
|
||||
getConfigs,
|
||||
checkConfigs,
|
||||
makeHeader,
|
||||
ListNotification,
|
||||
AckNotification,
|
||||
Wallet,
|
||||
hk4e_getConfigs,
|
||||
hk4e_makeHeader,
|
||||
hk4e_ListNotification,
|
||||
hk4e_AckNotification,
|
||||
hk4e_Wallet,
|
||||
hk4e_AppVersion,
|
||||
nap_getConfigs,
|
||||
nap_makeHeader,
|
||||
nap_ListNotification,
|
||||
nap_AckNotification,
|
||||
nap_Wallet,
|
||||
nap_AppVersion,
|
||||
SendLog,
|
||||
AppVersion,
|
||||
getGlobalConfig,
|
||||
SendResult,
|
||||
} = require("./config");
|
||||
@ -19,31 +25,34 @@ const nodemailer = require("nodemailer");
|
||||
log.info("开始获取全局配置");
|
||||
var globalConfig = getGlobalConfig();
|
||||
log.info("获取成功");
|
||||
if (globalConfig.sendMail == true) {
|
||||
log.info("组装邮件发射器");
|
||||
var transporter = nodemailer.createTransport({
|
||||
host: globalConfig.mailConfig.smtpServer,
|
||||
port: globalConfig.mailConfig.smtpPort,
|
||||
secure: globalConfig.mailConfig.smtpSecure,
|
||||
auth: {
|
||||
user: globalConfig.mailConfig.user,
|
||||
pass: globalConfig.mailConfig.pass,
|
||||
},
|
||||
});
|
||||
}
|
||||
log.info("组装邮件发射器");
|
||||
var transporter = nodemailer.createTransport({
|
||||
host: globalConfig.mailConfig.smtpServer,
|
||||
port: globalConfig.mailConfig.smtpPort,
|
||||
secure: globalConfig.mailConfig.smtpSecure,
|
||||
auth: {
|
||||
user: globalConfig.mailConfig.user,
|
||||
pass: globalConfig.mailConfig.pass,
|
||||
},
|
||||
});
|
||||
var minDelay = globalConfig.minDelay;
|
||||
var maxDelay = globalConfig.maxDelay;
|
||||
var configs = getConfigs();
|
||||
log.info(`正在检测配置有效性`);
|
||||
checkConfigs(configs);
|
||||
var hk4e_configs = hk4e_getConfigs();
|
||||
var nap_configs = nap_getConfigs();
|
||||
log.info(`正在检测原神配置有效性`);
|
||||
checkConfigs(hk4e_configs);
|
||||
log.info("检测完毕!");
|
||||
log.info(`正在检测绝区零配置有效性`);
|
||||
checkConfigs(nap_configs);
|
||||
log.info("检测完毕!");
|
||||
log.info("正在获取版本号");
|
||||
var appversion = await AppVersion();
|
||||
appversion = appversion.data.package_version;
|
||||
log.info(`获取成功!当前版本号:${appversion}`);
|
||||
var successNum = 0,
|
||||
totalNum = 0;
|
||||
for (key in configs) {
|
||||
var hk4e_appversion = await hk4e_AppVersion();
|
||||
var nap_appversion = await nap_AppVersion();
|
||||
hk4e_appversion = hk4e_appversion.data.package_version;
|
||||
nap_appversion = nap_appversion.data.package_version;
|
||||
log.info(`获取成功!当前版本号:原神${hk4e_appversion},绝区零${nap_appversion}`);
|
||||
var successNum = 0, totalNum = 0;
|
||||
for (key in hk4e_configs) {
|
||||
var delay = Math.round(
|
||||
Math.random() * (maxDelay - minDelay) + minDelay
|
||||
);
|
||||
@ -51,53 +60,114 @@ const nodemailer = require("nodemailer");
|
||||
await sleep(delay);
|
||||
totalNum++;
|
||||
log.info(`${key} - 正在执行配置 ${key}`);
|
||||
log.info(`${key} - 尝试签到……`);
|
||||
var header = makeHeader(configs[key], appversion);
|
||||
var WalletRespond = await Wallet(header);
|
||||
log.info(`${key} - 尝试签到原神……`);
|
||||
var hk4e_header = hk4e_makeHeader(hk4e_configs[key], hk4e_appversion);
|
||||
var hk4e_WalletRespond = await hk4e_Wallet(hk4e_header);
|
||||
addLogContent(
|
||||
`<span style="color: orange; font-weight: bold">${key} Wallet返回体</span> <br> <span style="color: orange">${JSON.stringify(
|
||||
WalletRespond
|
||||
`<span style="color: orange; font-weight: bold">${key} hk4e_Wallet返回体</span> <br> <span style="color: orange">${JSON.stringify(
|
||||
hk4e_WalletRespond
|
||||
)}</span><br>`
|
||||
);
|
||||
if (WalletRespond.data != null) {
|
||||
var NotificationRespond = await ListNotification(header);
|
||||
if (hk4e_WalletRespond.data != null) {
|
||||
var hk4e_NotificationRespond = await hk4e_ListNotification(hk4e_header);
|
||||
addLogContent(
|
||||
`<span style="color: orange; font-weight: bold">${key} Notification返回体</span> <br> <span style="color: orange">${JSON.stringify(
|
||||
NotificationRespond
|
||||
`<span style="color: orange; font-weight: bold">${key} hk4e_Notification返回体</span> <br> <span style="color: orange">${JSON.stringify(
|
||||
hk4e_NotificationRespond
|
||||
)}</span><br>`
|
||||
);
|
||||
successNum++;
|
||||
log.info(
|
||||
`${key} - 签到完毕! 获得时长:${WalletRespond.data.free_time.send_freetime}分钟,总时长:${WalletRespond.data.free_time.free_time}分钟`
|
||||
`${key} - 签到完毕! 原神获得时长:${hk4e_WalletRespond.data.free_time.send_freetime}分钟,总时长:${hk4e_WalletRespond.data.free_time.free_time}分钟`
|
||||
);
|
||||
if (configs[key].email != null) {
|
||||
if (hk4e_configs[key].email != null) {
|
||||
SendResult(
|
||||
transporter,
|
||||
globalConfig.mailConfig.user,
|
||||
configs[key].email,
|
||||
`签到完毕! 获得时长:${WalletRespond.data.free_time.send_freetime}分钟,总时长:${WalletRespond.data.free_time.free_time}分钟`,
|
||||
hk4e_configs[key].email,
|
||||
`签到完毕! 获得时长:${hk4e_WalletRespond.data.free_time.send_freetime}分钟,总时长:${hk4e_WalletRespond.data.free_time.free_time}分钟`,
|
||||
key
|
||||
);
|
||||
}
|
||||
let NotificationLength = NotificationRespond.data.list.length;
|
||||
let postHeader = header;
|
||||
Object.assign(postHeader, {
|
||||
let hk4e_NotificationLength = hk4e_NotificationRespond.data.list.length;
|
||||
let hk4e_postHeader = hk4e_header;
|
||||
Object.assign(hk4e_postHeader, {
|
||||
"Content-Length": 28,
|
||||
"Content-Type": "application/json; charset=UTF-8",
|
||||
});
|
||||
for (var i = 0; i < NotificationLength; i++) {
|
||||
AckNotification(
|
||||
postHeader,
|
||||
NotificationRespond.data.list[i].id
|
||||
for (var i = 0; i < hk4e_NotificationLength; i++) {
|
||||
hk4e_AckNotification(
|
||||
hk4e_postHeader,
|
||||
hk4e_NotificationRespond.data.list[i].id
|
||||
);
|
||||
}
|
||||
} else {
|
||||
log.error(`${key} - 签到失败`);
|
||||
if (configs[key].email != null) {
|
||||
if (hk4e_configs[key].email != null) {
|
||||
SendResult(
|
||||
transporter,
|
||||
globalConfig.mailConfig.user,
|
||||
configs[key].email,
|
||||
hk4e_configs[key].email,
|
||||
"签到失败",
|
||||
key
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (key in nap_configs) {
|
||||
var delay = Math.round(
|
||||
Math.random() * (maxDelay - minDelay) + minDelay
|
||||
);
|
||||
log.info(`暂停:${delay}毫秒`);
|
||||
await sleep(delay);
|
||||
totalNum++;
|
||||
log.info(`${key} - 正在执行配置 ${key}`);
|
||||
log.info(`${key} - 尝试签到绝区零……`);
|
||||
var nap_header = nap_makeHeader(nap_configs[key], nap_appversion);
|
||||
var nap_WalletRespond = await nap_Wallet(nap_header);
|
||||
addLogContent(
|
||||
`<span style="color: orange; font-weight: bold">${key} nap_Wallet返回体</span> <br> <span style="color: orange">${JSON.stringify(
|
||||
nap_WalletRespond
|
||||
)}</span><br>`
|
||||
);
|
||||
if (nap_WalletRespond.data != null) {
|
||||
var nap_NotificationRespond = await nap_ListNotification(nap_header);
|
||||
addLogContent(
|
||||
`<span style="color: orange; font-weight: bold">${key} nap_Notification返回体</span> <br> <span style="color: orange">${JSON.stringify(
|
||||
nap_NotificationRespond
|
||||
)}</span><br>`
|
||||
);
|
||||
successNum++;
|
||||
log.info(
|
||||
`${key} - 签到完毕! 绝区零获得时长:${nap_WalletRespond.data.free_time.send_freetime}分钟,总时长:${nap_WalletRespond.data.free_time.free_time}分钟`
|
||||
);
|
||||
if (nap_configs[key].email != null) {
|
||||
SendRnapt(
|
||||
transporter,
|
||||
globalConfig.mailConfig.user,
|
||||
nap_configs[key].email,
|
||||
`签到完毕! 获得时长:${nap_WalletRespond.data.free_time.send_freetime}分钟,总时长:${nap_WalletRespond.data.free_time.free_time}分钟`,
|
||||
key
|
||||
);
|
||||
}
|
||||
let nap_NotificationLength = nap_NotificationRespond.data.list.length;
|
||||
let nap_postHeader = nap_header;
|
||||
Object.assign(nap_postHeader, {
|
||||
"Content-Length": 28,
|
||||
"Content-Type": "application/json; charset=UTF-8",
|
||||
});
|
||||
for (var i = 0; i < nap_NotificationLength; i++) {
|
||||
nap_AckNotification(
|
||||
nap_postHeader,
|
||||
nap_NotificationRespond.data.list[i].id
|
||||
);
|
||||
}
|
||||
} else {
|
||||
log.error(`${key} - 签到失败`);
|
||||
if (nap_configs[key].email != null) {
|
||||
SendResult(
|
||||
transporter,
|
||||
globalConfig.mailConfig.user,
|
||||
nap_configs[key].email,
|
||||
"签到失败",
|
||||
key
|
||||
);
|
||||
|
Reference in New Issue
Block a user