Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Liqu0012 committed Dec 15, 2023
1 parent 516285c commit d1168bf
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
const glados = async () => {
const cookie = process.env.GLADOS
if (!cookie) return
const gladosTask = async (cookie) => {
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())
}).then((r) => r.json());
const status = await fetch('https://glados.rocks/api/user/status', {
method: 'GET',
headers,
}).then((r) => r.json())
}).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
Expand All @@ -46,7 +45,16 @@ const notify = async (contents) => {
}

const main = async () => {
await notify(await glados())
}
const results = await Promise.all([
gladosTask(process.env.GLADOS),
gladosTask(process.env.GLADOS2)
]);

for (const result of results) {
if (result) {
await notify(result);
}
}
};

main()
main();

0 comments on commit d1168bf

Please sign in to comment.