Files
sdu-course-bot/src/draw.ts
2022-02-28 08:35:03 +08:00

47 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {countStr, getTimeNow, logAndNotifyUser, resetCookie, sduAxios, sleep} from "./includes"
import * as fs from "fs"
export async function draw() {
while (true) {
let html = ''
try {
let resp = await sduAxios.get("jsxsd/xsxkjg/comeXkjglb?isktx=true")
html = JSON.stringify(resp.data)
} catch (e) {
console.log(e)
}
if (countStr(html, 'cqOper') < 2) {
logAndNotifyUser('登录失败重设cookie ' + getTimeNow())
try {
await resetCookie()
} catch (e) {
console.log(e)
}
continue
}
if (countStr(html, 'cqOper') > 2) {
logAndNotifyUser('可以抽签,正在进行抽签')
fs.writeFileSync('draw-' + Date.now() + '.html', html)
let arr = [
'2021202222605',// 英语
'2021202225984',// 周易
'2021202225817',// 刻瓷
'2021202222614',// 众智
'2021202222613',// 移动互联网
]
for (let id of arr) {
try {
let resp = await sduAxios.get('/jsxsd/xsxkjg/xscqOper?jx0404id=' + id + '&cqqk=3')// 3抽的中2抽不中
logAndNotifyUser(JSON.stringify(resp.data))
} catch (e) {
console.log(e)
}
}
}
console.log('轮询中:' + getTimeNow())
await sleep(1000)
}
}
draw()