比較提交
沒有共同的提交。「9567fbb889cfa13baa1207bf3116e2d4d00931e9」和「a0ef04285e0840075a2f6be354a05443f8f32ea0」的歷史完全不同。
9567fbb889
...
a0ef04285e
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,4 +4,3 @@ node_modules/*
|
||||
/pnpm-lock.yaml
|
||||
/arr.json
|
||||
backup
|
||||
resetCookieRequest.txt
|
||||
|
@ -5,9 +5,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "ts-node src/test.ts",
|
||||
"start": "ts-node src/index.ts",
|
||||
"draw": "ts-node src/draw.ts",
|
||||
"resetCookie": "ts-node src/resetCookieRequest.ts"
|
||||
"start": "ts-node src/index.ts"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
46
src/draw.ts
46
src/draw.ts
@ -1,46 +0,0 @@
|
||||
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()
|
@ -43,14 +43,10 @@ export async function logAndNotifyUser(text: string) {
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded'
|
||||
// }
|
||||
// })
|
||||
try {
|
||||
await axios.post('https://' + appConfig.tgApiDomain + '/bot' + appConfig.tgApiKey + '/sendMessage', qs.stringify({
|
||||
chat_id: appConfig.tgChatId,
|
||||
text: text
|
||||
}))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
export function sleep(ms: number) {
|
||||
|
@ -3,10 +3,8 @@ import {appConfig} from "./config"
|
||||
import {acquireProcess, monitProcess, replaceProcess} from "./actions"
|
||||
import {resetCookie, sleep} from "./includes"
|
||||
import {health} from "./health"
|
||||
import * as fs from "fs"
|
||||
|
||||
async function start() {
|
||||
fs.writeFileSync('resetCookieRequest.txt','0')
|
||||
console.log('开始获取Cookie')
|
||||
await resetCookie()
|
||||
console.log('开始启动轮询进程')
|
||||
|
15
src/poll.ts
15
src/poll.ts
@ -2,7 +2,6 @@ import {IJsonCourse} from "./types"
|
||||
import {getTimeNow, logAndNotifyUser, resetCookie, sduAxios, sleep} from "./includes"
|
||||
import {appConfig} from "./config"
|
||||
import * as qs from "qs"
|
||||
import * as fs from "fs"
|
||||
|
||||
export let reqBody = 'sEcho=1&iColumns=15&sColumns=&iDisplayStart=0&iDisplayLength=2000&mDataProp_0=kch&mDataProp_1=kcmc&mDataProp_2=kxhnew&mDataProp_3=jkfs&mDataProp_4=xmmc&mDataProp_5=fzmc&mDataProp_6=ktmc&mDataProp_7=xf&mDataProp_8=skls&mDataProp_9=sksj&mDataProp_10=skdd&mDataProp_11=xqmc&mDataProp_12=syrs&mDataProp_13=ctsm&mDataProp_14=czOper'
|
||||
let currentErrorCount = 0
|
||||
@ -60,7 +59,6 @@ async function updateRx() {
|
||||
}
|
||||
|
||||
export async function poll() {
|
||||
await checkResetCookieRequest()
|
||||
if (appConfig.channels.includes('bx')) {
|
||||
await updateBx()
|
||||
await sleep(appConfig.interval)
|
||||
@ -76,19 +74,6 @@ export async function poll() {
|
||||
setImmediate(poll)
|
||||
}
|
||||
|
||||
async function checkResetCookieRequest() {
|
||||
let req = parseInt(fs.readFileSync('resetCookieRequest.txt').toString())
|
||||
if (req) {
|
||||
try {
|
||||
await resetCookie()
|
||||
logAndNotifyUser('[resetCookie]成功')
|
||||
fs.writeFileSync('resetCookieRequest.txt', '0')
|
||||
} catch (e) {
|
||||
logAndNotifyUser('[resetCookie]失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function processError(e: Error) {
|
||||
currentErrorCount++
|
||||
if (currentErrorCount >= 30) {
|
||||
|
@ -1,4 +0,0 @@
|
||||
import * as fs from "fs"
|
||||
|
||||
fs.writeFileSync('resetCookieRequest.txt','1')
|
||||
console.log('已请求resetCookie')
|
24
src/test.ts
24
src/test.ts
@ -1,5 +1,5 @@
|
||||
import {appConfig} from "./config"
|
||||
import {countStr, logAndNotifyUser, sduAxios, sleep} from "./includes"
|
||||
import {logAndNotifyUser, sduAxios} from "./includes"
|
||||
import {reqBody} from "./poll"
|
||||
import * as fs from "fs"
|
||||
import {IJsonCourse} from "./types"
|
||||
@ -29,27 +29,7 @@ async function test() {
|
||||
// for (let course of courseList) {
|
||||
// console.log(course.kcmc + ' ' + course.kch + ' ' + course.kxh + ' ' + course.syrs + ' ' + course.xf)
|
||||
// }
|
||||
// let lastData = ''
|
||||
// let first=true
|
||||
// let count=0
|
||||
// while (true) {
|
||||
// let resp = await sduAxios.get("jsxsd/xsxkjg/comeXkjglb?isktx=true", {
|
||||
// headers: {
|
||||
// 'Cookie': 'bzb_jsxsd=329BCA4E7D8E2421309B14C02587784F; bzb_njw=55FFC1D9D9B2EF5A10D3F28BEC294AE1; SERVERID=123'
|
||||
// }
|
||||
// })
|
||||
// if (resp.data !== lastData && !first) {
|
||||
// logAndNotifyUser('可以抽签了')
|
||||
// first=false
|
||||
// break
|
||||
// }
|
||||
// lastData = resp.data
|
||||
// console.log('rotate '+count)
|
||||
// count++
|
||||
// await sleep(1000)
|
||||
// }
|
||||
let str=fs.readFileSync('backup/2.html')
|
||||
console.log(countStr(JSON.stringify(str.toString()),'cqOper'))
|
||||
logAndNotifyUser('log test')
|
||||
}
|
||||
|
||||
test()
|
||||
|
載入中…
x
新增問題並參考
Block a user