diff --git a/.gitignore b/.gitignore index bb1f1ad..166911b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /config.yaml node_modules/* /pnpm-lock.yaml -/arr.json \ No newline at end of file +/arr.json +backup diff --git a/src/includes.ts b/src/includes.ts index e191503..2c5f1ef 100644 --- a/src/includes.ts +++ b/src/includes.ts @@ -79,6 +79,9 @@ export async function acquireCourse(course: IJsonCourse, channel: TChannel): Pro if (resp.data.success === true) { return true } else { + if(resp.data.message.includes('当前账号已在别处登录')){ + await resetCookie() + } logAndNotifyUser(resp.data.message) return false } @@ -93,6 +96,9 @@ export async function exitCourse(course: IJsonCourse): Promise { if (resp.data.success === true) { return true } else { + if(resp.data.message.includes('当前账号已在别处登录')){ + await resetCookie() + } logAndNotifyUser('[exitCourse]退课失败:' + resp.data.message) return false } @@ -140,4 +146,8 @@ export async function resetCookie() { sduAxios.defaults.headers['Cookie'] = cookieString } +export function countStr(str: string, word: string) { + return str.split(word).length - 1 +} + export {sduAxios} diff --git a/src/index.ts b/src/index.ts index 08932fb..4e8f32f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,14 +22,19 @@ async function start() { await sleep(50) } console.log('轮询进程启动完毕') + for (let channel of appConfig.channels) { + console.log('channel: ' + channel + ': ' + JsonCourseList[channel].length) + } console.log('开始启动用户进程') for (let course of appConfig.monit?.list || []) { monitProcess(course) } for (let course of appConfig.acquire?.list || []) { + console.log('添加抢课课程:' + course.kch + ' ' + course.kxh) acquireProcess(course) } if (appConfig.replace) { + console.log('添加换课课程:' + appConfig.replace.exit.kch + ' ' + appConfig.replace.exit.kxh) replaceProcess(appConfig.replace.list, appConfig.replace.exit) } console.log('用户进程启动完毕')