-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGLaDOS_Checkin.js
116 lines (100 loc) · 3.68 KB
/
GLaDOS_Checkin.js
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
const axios = require('axios');
const COOKIES = '这里填入你的cookie';
const Bytes2GB = 1073741824;
const checkIn = async (cookie) => {
return axios({
method: 'post',
url: 'https://glados.rocks/api/user/checkin',
headers: {
'Cookie': cookie,
'origin': 'https://glados.rocks',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36',
'content-type': 'application/json;charset=UTF-8',
'content-length': 26
},
data: {
token: "glados.network"
}
});
};
const getStatus = async (cookie) => {
return axios({
method: 'get',
url: 'https://glados.rocks/api/user/status',
headers: {
'Cookie': cookie
}
});
};
const checkInAndGetStatus = async (cookie) => {
const checkInMessage = (await checkIn(cookie))?.data?.message;
const userStatus = (await getStatus(cookie))?.data?.data;
const email = userStatus?.email;
const leftDays = parseInt(userStatus?.leftDays);
const traffic = (parseInt(userStatus?.traffic) / Bytes2GB).toFixed(2);
const usedDays = parseInt(userStatus?.days);
return {
'账号': email,
'天数': leftDays,
'流量': traffic,
'已用天数': usedDays,
'签到情况': checkInMessage
};
};
const pushplus = (token, infos) => {
const titleEmail = infos?.[0]['账号'];
const titleLeftDays = infos?.[0]['天数'];
const titleCheckInMessage = infos?.[0]['签到情况'];
const titleSpace = 4;
const title = (
'账号: ' + `${titleEmail}`.padEnd(titleEmail.length + titleSpace) +
'天数: ' + `${titleLeftDays}`.padEnd(titleLeftDays.toString().length + titleSpace) +
'签到情况: ' + `${titleCheckInMessage}`
).slice(0, 100);
const data = {
token,
title,
content: JSON.stringify(infos),
template: 'json'
};
console.log(data);
return axios({
method: 'post',
url: `http://www.pushplus.plus/send`,
data
});
};
const printLog = (infos) => {
const contentEmail = infos?.[0]['账号'];
const contentLeftDays = infos?.[0]['天数'];
const contentCheckInMessage = infos?.[0]['签到情况'];
const contentTraffic = infos?.[0]['流量'];
const contentUsedDays = infos?.[0]['已用天数'];
const contentLine = '\n';
const titleSpace = 4;
const content = (
'账号: ' + `${contentEmail}`.padEnd(contentEmail.length + titleSpace) + contentLine +
'天数: ' + `${contentLeftDays}`.padEnd(contentLeftDays.toString().length + titleSpace) + contentLine +
'流量: ' + `${contentTraffic}`.padEnd(contentTraffic.length) + 'GB'.padEnd('GB'.length + titleSpace) + contentLine +
'已用天数: ' + `${contentUsedDays}`.padEnd(contentUsedDays.toString().length + titleSpace) + contentLine +
'签到情况: ' + `${contentCheckInMessage}`
).slice(0, 100);
return content;
}
const GLaDOSCheckIn = async () => {
try {
console.log('GLaDOS,开始签到:')
// const cookies = process.env.COOKIES?.split('&&') ?? [];
const cookies = COOKIES.split('&&') ?? [];
const infos = await Promise.all(cookies.map(async cookie => await checkInAndGetStatus(cookie)));
console.log(printLog(infos));
// const PUSHPLUS = process.env.PUSHPLUS;
// if (PUSHPLUS && infos.length) {
// const pushResult = (await pushplus(PUSHPLUS, infos))?.data?.msg;
// console.log(pushResult);
// }
} catch (error) {
console.log(error);
}
};
GLaDOSCheckIn();