-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunInQl
More file actions
119 lines (109 loc) · 3.73 KB
/
runInQl
File metadata and controls
119 lines (109 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* 任务名称
* name: cloud189_checkIn
* 定时规则
* cron: 1 9 * * *
*/
const { sendNotify } = require('./sendNotify.js');
const { CloudClient } = require("cloud189-sdk")
const mask = (s, start, end) => s.split("").fill("*", start, end).join("");
// 任务 1.签到 2.天天抽红包 3.自动备份抽红包
const doTask = async (cloudClient) => {
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const result = [];
const res1 = await cloudClient.userSign();
result.push(
`${res1.isSign ? "已经签到过了," : ""}签到获得${res1.netdiskBonus}M空间`
);
await delay(5000); // 延迟5秒
let index = 1;
const buildResult = (index, res) => {
console.log(res.errorCode)
if (res.errorCode === "User_Not_Chance") {
result.push(`第${index}次抽奖失败,次数不足`);
} else if(res.errorCode === "RequestFrequent") {
result.push(`第${index}次抽奖失败,请求频繁`)
} else {
result.push(`第${index}次抽奖成功,抽奖获得${res.prizeName}`);
}
};
const res2 = await cloudClient.taskSign();
buildResult(index, res2);
index++;
await delay(5000); // 延迟5秒
const res3 = await cloudClient.taskPhoto();
buildResult(index, res3);
index++;
await delay(5000); // 延迟5秒
const res4 = await cloudClient.taskKJ();
buildResult(index, res4);
return result;
}
const doFamilyTask = async (cloudClient) => {
const { familyInfoResp } = await cloudClient.getFamilyList();
const result = [];
if (familyInfoResp) {
for (let index = 0; index < familyInfoResp.length; index += 1) {
const { familyId } = familyInfoResp[index];
const res = await cloudClient.familyUserSign(familyId);
result.push(
"家庭任务" +
`${res.signStatus ? "已经签到过了," : ""}签到获得${res.bonusSpace
}M空间`
);
}
}
return result;
}
const USERNAME = process.env["CLOUD189_USER"]
const PASSWORD = process.env["CLOUD189_PASS"]
// 开始执行程序
async function main() {
if (USERNAME && PASSWORD) {
const logMessages = [];
const userNameInfo = mask(USERNAME, 2, 8);
const double_log = (info) => {
console.log(info);
logMessages.push(info);
}
try {
double_log(`账户 ${userNameInfo}开始执行`)
const cloudClient = new CloudClient(USERNAME, PASSWORD);
await cloudClient.login();
const result = await doTask(cloudClient);
result.forEach((r) => double_log(r));
const familyResult = await doFamilyTask(cloudClient);
familyResult.forEach((r) => double_log(r));
const { cloudCapacityInfo, familyCapacityInfo } =
await cloudClient.getUserSizeInfo();
double_log(
`个人总容量:${(
cloudCapacityInfo.totalSize /
1024 /
1024 /
1024
).toFixed(2)}G,家庭总容量:${(
familyCapacityInfo.totalSize /
1024 /
1024 /
1024
).toFixed(2)}G`
);
} catch (e) {
if (e.code === "ECONNRESET") {
throw e;
}
} finally {
double_log(`账户 ${userNameInfo}执行完毕`);
}
var content = ""
logMessages.forEach((r) => {
content += r
content += "\n"
})
sendNotify("天翼云盘自动签到任务", content)
}
}
(async () => {
await main();
})();