handle dialog about /剩\d+次沟通机会/ during startup chat

This commit is contained in:
geekgeekrun
2025-12-12 22:02:57 +08:00
parent cd09210017
commit f27ca4145a
@@ -1280,6 +1280,7 @@ async function toRecommendPage (hooks) {
//#region click the chat button //#region click the chat button
await startChatButtonProxy.click() await startChatButtonProxy.click()
const waitAddFriendResponse = async () => {
const addFriendResponse = await page.waitForResponse( const addFriendResponse = await page.waitForResponse(
response => { response => {
if ( if (
@@ -1291,8 +1292,9 @@ async function toRecommendPage (hooks) {
} }
); );
const res = await addFriendResponse.json() const res = await addFriendResponse.json()
return res
if (res.code === 0) { }
const waitAndHandleChatSuccess = async () => {
await hooks.newChatStartup?.promise( await hooks.newChatStartup?.promise(
targetJobData, targetJobData,
{ {
@@ -1308,10 +1310,16 @@ async function toRecommendPage (hooks) {
await closeDialogButtonProxy.click() await closeDialogButtonProxy.click()
await sleepWithRandomDelay(2000) await sleepWithRandomDelay(2000)
} }
// TODO: const handleAddFriendResponse = async (res) => {
// else if (res.zpData.bizCode === 1 && res.zpData.bizData?.chatRemindDialog?.blockLevel === 0 && /还剩\d+次沟通机会/.test(res.zpData.bizData?.chatRemindDialog?.content)) { if (res.code === 0) {
// debugger await waitAndHandleChatSuccess()
// } }
else if (res.zpData.bizCode === 1 && res.zpData.bizData?.chatRemindDialog?.blockLevel === 0 && /剩\d+次沟通机会/.test(res.zpData.bizData?.chatRemindDialog?.content)) {
const confirmButton = await page.waitForSelector('.chat-block-dialog .chat-block-footer .sure-btn')
await confirmButton.click()
const nextRes = await waitAddFriendResponse()
await handleAddFriendResponse(nextRes)
}
else if ( else if (
res.zpData.bizCode === 1 && res.zpData.bizCode === 1 &&
res.zpData.bizData?.chatRemindDialog?.blockLevel === 0 && res.zpData.bizData?.chatRemindDialog?.blockLevel === 0 &&
@@ -1330,6 +1338,9 @@ async function toRecommendPage (hooks) {
) )
throw new Error('STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR') throw new Error('STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR')
} }
}
const res = await waitAddFriendResponse()
await handleAddFriendResponse(res)
// #endregion // #endregion
} catch (err) { } catch (err) {
if (err instanceof Error) { if (err instanceof Error) {