forked from actions-integration/checkin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
52 lines (49 loc) · 1.34 KB
/
main.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
const glados = async () => {
const cookie = process.env.GLADOS
if (!cookie) return
try {
const headers = {
'cookie': cookie,
'referer': 'https://glados.rocks/console/checkin',
'user-agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)',
}
const checkin = await fetch('https://glados.rocks/api/user/checkin', {
method: 'POST',
headers: { ...headers, 'content-type': 'application/json' },
body: '{"token":"glados.one"}',
}).then((r) => r.json())
const status = await fetch('https://glados.rocks/api/user/status', {
method: 'GET',
headers,
}).then((r) => r.json())
return [
'Checkin OK',
`${checkin.message}`,
`Left Days ${Number(status.data.leftDays)}`,
]
} catch (error) {
return [
'Checkin Error',
`${error}`,
`<${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}>`,
]
}
}
const notify = async (contents) => {
const token = process.env.NOTIFY
if (!token || !contents) return
await fetch(`https://www.pushplus.plus/send`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
token,
title: contents[0],
content: contents.join('<br>'),
template: 'markdown',
}),
})
}
const main = async () => {
await notify(await glados())
}
main()