比較提交
1 次程式碼提交
作者 | SHA1 | 日期 | |
---|---|---|---|
599e4c5855 |
1
.gitignore
已供應
1
.gitignore
已供應
@@ -4,4 +4,3 @@ node_modules/*
|
|||||||
/pnpm-lock.yaml
|
/pnpm-lock.yaml
|
||||||
/arr.json
|
/arr.json
|
||||||
backup
|
backup
|
||||||
resetCookieRequest.txt
|
|
||||||
|
@@ -23,3 +23,4 @@ vim config.yaml # 根据配置文件内部的注释编辑
|
|||||||
npm start # 启动脚本
|
npm start # 启动脚本
|
||||||
```
|
```
|
||||||
|
|
||||||
|
如果你还是不会,请去看detail版
|
||||||
|
二進制
assets/0.png
一般檔案
二進制
assets/0.png
一般檔案
未顯示二進位檔案。
之後 寬度: | 高度: | 大小: 29 KiB |
二進制
assets/1.png
一般檔案
二進制
assets/1.png
一般檔案
未顯示二進位檔案。
之後 寬度: | 高度: | 大小: 197 KiB |
二進制
assets/2.png
一般檔案
二進制
assets/2.png
一般檔案
未顯示二進位檔案。
之後 寬度: | 高度: | 大小: 197 KiB |
二進制
assets/3.png
一般檔案
二進制
assets/3.png
一般檔案
未顯示二進位檔案。
之後 寬度: | 高度: | 大小: 52 KiB |
@@ -5,9 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "ts-node src/test.ts",
|
"test": "ts-node src/test.ts",
|
||||||
"start": "ts-node src/index.ts",
|
"start": "ts-node src/index.ts"
|
||||||
"draw": "ts-node src/draw.ts",
|
|
||||||
"resetCookie": "ts-node src/resetCookieRequest.ts"
|
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
34
readme_detail.md
一般檔案
34
readme_detail.md
一般檔案
@@ -0,0 +1,34 @@
|
|||||||
|
首先,确保你安装了nodejs
|
||||||
|
|
||||||
|
将config.yaml.example 直接改名为config.yaml(注意你可能设置了隐藏文件后缀)
|
||||||
|
|
||||||
|
打开这个文件,编辑cookie和要抢的课
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
这个界面,按f12找到控制台,
|
||||||
|

|
||||||
|
找到这个界面,然后点进入选课的按钮,把监听到的这个cookie复制到文件的cookie属性的值里
|
||||||
|

|
||||||
|
要复制全
|
||||||
|
|
||||||
|
然后编辑你想抢的课,其余的不用管
|
||||||
|
|
||||||
|
然后在项目文件夹目录下(就是sdu-course-bot文件夹)启动cmd(确保你的cmd路径是这个文件夹)
|
||||||
|
|
||||||
|
执行
|
||||||
|
|
||||||
|
```
|
||||||
|
npm i
|
||||||
|
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
成功的话:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
(注意路径,然后静待就好)(不要把这个cmd关掉)
|
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'
|
// 'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
try {
|
|
||||||
await axios.post('https://' + appConfig.tgApiDomain + '/bot' + appConfig.tgApiKey + '/sendMessage', qs.stringify({
|
await axios.post('https://' + appConfig.tgApiDomain + '/bot' + appConfig.tgApiKey + '/sendMessage', qs.stringify({
|
||||||
chat_id: appConfig.tgChatId,
|
chat_id: appConfig.tgChatId,
|
||||||
text: text
|
text: text
|
||||||
}))
|
}))
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sleep(ms: number) {
|
export function sleep(ms: number) {
|
||||||
|
@@ -3,10 +3,8 @@ import {appConfig} from "./config"
|
|||||||
import {acquireProcess, monitProcess, replaceProcess} from "./actions"
|
import {acquireProcess, monitProcess, replaceProcess} from "./actions"
|
||||||
import {resetCookie, sleep} from "./includes"
|
import {resetCookie, sleep} from "./includes"
|
||||||
import {health} from "./health"
|
import {health} from "./health"
|
||||||
import * as fs from "fs"
|
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
fs.writeFileSync('resetCookieRequest.txt','0')
|
|
||||||
console.log('开始获取Cookie')
|
console.log('开始获取Cookie')
|
||||||
await resetCookie()
|
await resetCookie()
|
||||||
console.log('开始启动轮询进程')
|
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 {getTimeNow, logAndNotifyUser, resetCookie, sduAxios, sleep} from "./includes"
|
||||||
import {appConfig} from "./config"
|
import {appConfig} from "./config"
|
||||||
import * as qs from "qs"
|
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'
|
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
|
let currentErrorCount = 0
|
||||||
@@ -60,7 +59,6 @@ async function updateRx() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function poll() {
|
export async function poll() {
|
||||||
await checkResetCookieRequest()
|
|
||||||
if (appConfig.channels.includes('bx')) {
|
if (appConfig.channels.includes('bx')) {
|
||||||
await updateBx()
|
await updateBx()
|
||||||
await sleep(appConfig.interval)
|
await sleep(appConfig.interval)
|
||||||
@@ -76,19 +74,6 @@ export async function poll() {
|
|||||||
setImmediate(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) {
|
async function processError(e: Error) {
|
||||||
currentErrorCount++
|
currentErrorCount++
|
||||||
if (currentErrorCount >= 30) {
|
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 {appConfig} from "./config"
|
||||||
import {countStr, logAndNotifyUser, sduAxios, sleep} from "./includes"
|
import {logAndNotifyUser, sduAxios} from "./includes"
|
||||||
import {reqBody} from "./poll"
|
import {reqBody} from "./poll"
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
import {IJsonCourse} from "./types"
|
import {IJsonCourse} from "./types"
|
||||||
@@ -29,27 +29,7 @@ async function test() {
|
|||||||
// for (let course of courseList) {
|
// for (let course of courseList) {
|
||||||
// console.log(course.kcmc + ' ' + course.kch + ' ' + course.kxh + ' ' + course.syrs + ' ' + course.xf)
|
// console.log(course.kcmc + ' ' + course.kch + ' ' + course.kxh + ' ' + course.syrs + ' ' + course.xf)
|
||||||
// }
|
// }
|
||||||
// let lastData = ''
|
logAndNotifyUser('log test')
|
||||||
// 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'))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
新增問題並參考
封鎖使用者