mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-08 00:47:15 +08:00
handle today chance used out
This commit is contained in:
+45
-37
@@ -187,51 +187,59 @@ async function mainLoop () {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
try {
|
const res = await addFriendResponse.json()
|
||||||
const res = await addFriendResponse.json()
|
|
||||||
|
if (res.code !== 0) {
|
||||||
if (res.code !== 0) {
|
// startup chat error, may the chance of today has used out
|
||||||
console.err(res)
|
if (res.zpData.bizCode === 1 && res.zpData.bizData?.chatRemindDialog?.blockLevel === 0 && res.zpData.bizData?.chatRemindDialog?.content === `今日沟通人数已达上限,请明天再试`) {
|
||||||
break
|
throw new Error('STARTUP_CHAT_ERROR_DUE_TO_TODAY_CHANCE_HAS_USED_OUT')
|
||||||
}
|
} else {
|
||||||
} catch(err) {
|
console.error(res)
|
||||||
// console.warn(err)
|
throw new Error('STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR')
|
||||||
} finally {
|
|
||||||
//#region TODO: temporary work with legacy logic
|
|
||||||
await sleep(500)
|
|
||||||
const continueChatButtonProxy = await page.$('.greet-boss-dialog .greet-boss-footer .sure-btn')
|
|
||||||
|
|
||||||
await continueChatButtonProxy.click()
|
|
||||||
//#endregion
|
|
||||||
await sleepWithRandomDelay(2500)
|
|
||||||
if (page.url().startsWith('https://www.zhipin.com/web/geek/chat')) {
|
|
||||||
await sleepWithRandomDelay(3000)
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation(),
|
|
||||||
page.goBack(),
|
|
||||||
])
|
|
||||||
await sleepWithRandomDelay(1000)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
blockBossNotNewChat.add(jobData.jobInfo.encryptUserId)
|
||||||
|
|
||||||
|
await sleepWithRandomDelay(750)
|
||||||
|
const closeDialogButtonProxy = await page.$('.greet-boss-dialog .greet-boss-footer .cancel-btn')
|
||||||
|
await closeDialogButtonProxy.click()
|
||||||
|
await sleepWithRandomDelay(1000)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
blockBossNotNewChat.add(jobData.jobInfo.encryptUserId)
|
blockBossNotNewChat.add(jobData.jobInfo.encryptUserId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof Error && err.message === 'CANNOT_FIND_EXCEPT_JOB') {
|
if (err instanceof Error) {
|
||||||
if (
|
switch (err.message) {
|
||||||
currentExceptJobIndex + 1 > expectJobList.length
|
case 'CANNOT_FIND_EXCEPT_JOB': {
|
||||||
) {
|
if (
|
||||||
await Promise.all([
|
currentExceptJobIndex + 1 > expectJobList.length
|
||||||
page.reload(),
|
) {
|
||||||
page.waitForNavigation()
|
await Promise.all([
|
||||||
])
|
page.reload(),
|
||||||
currentExceptJobIndex = INIT_START_EXCEPT_JOB_INDEX
|
page.waitForNavigation()
|
||||||
} else {
|
])
|
||||||
currentExceptJobIndex += 1
|
currentExceptJobIndex = INIT_START_EXCEPT_JOB_INDEX
|
||||||
|
} else {
|
||||||
|
currentExceptJobIndex += 1
|
||||||
|
}
|
||||||
|
continue afterPageLoad;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'STARTUP_CHAT_ERROR_DUE_TO_TODAY_CHANCE_HAS_USED_OUT': {
|
||||||
|
let nextTrySeconds = 60 * 60
|
||||||
|
console.error(`Today chance has used out. Just explore positions you\'ve chatted. New chat will be tried to start after ${nextTrySeconds} seconds.`)
|
||||||
|
await sleep(nextTrySeconds * 1000)
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
case 'STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR': {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue afterPageLoad;
|
|
||||||
} else {
|
} else {
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user