diff --git a/packages/ui/src/main/flow/LAUNCH_BOSS_SITE/index.ts b/packages/ui/src/main/flow/LAUNCH_BOSS_SITE/index.ts index 4e35ebc..19858ae 100644 --- a/packages/ui/src/main/flow/LAUNCH_BOSS_SITE/index.ts +++ b/packages/ui/src/main/flow/LAUNCH_BOSS_SITE/index.ts @@ -181,9 +181,14 @@ const attachRequestsListener = async (target: Target) => { const url = new URL(request) const encryptBossIdInAddFriendUrl = url.searchParams.get('bossId') - const bossInfo: any = await page.evaluate( - 'document.querySelector(".chat-conversation").__vue__.bossInfo$' - ) + const bossInfo = + (await page.evaluate( + 'document.querySelector(".chat-conversation .chat-record")?.__vue__?.boss' + )) ?? null + if (!bossInfo) { + console.warn('cannot find boss info on page.') + return + } const ds = await dbInitPromise // save boss info const bossInfoRepository = ds.getRepository(BossInfo) @@ -206,15 +211,24 @@ const attachRequestsListener = async (target: Target) => { const rawChatRecordList = ( await page.evaluate( - 'document.querySelector(".message-content .chat-record").__vue__.records$' + 'document.querySelector(".message-content .chat-record").__vue__.list$' ) - )?.filter((msg) => ['received', 'sent'].includes(msg.style)) ?? [] + )?.filter((it) => { + return ( + it.status !== 3 && // filter system notification out + it.templateId === 1 && // filter system notification out + ( + (['text', 'sticker', 'image', 'sound', 'comDesc'].includes(it.messageType) && !it.extend?.greetingQuestionAnswer) // include those message, filter out auto ask + || (it.messageType === 'dialog' && [0, 1, 2, 8, 11, 12, 14, 17, 33].includes(it?.dialog?.type)) // include message like resume, phone, map, etc., filter out auto ask + ) + ) + }) ?? [] const chatRecordList = rawChatRecordList.map(it => { const mappedItem = {} as InstanceType mappedItem.mid = it.mid - mappedItem.encryptFromUserId = it.style === 'sent' ? currentUserInfo.encryptUserId : it.style === 'received' ? bossInfo.encryptBossId : '' - mappedItem.encryptToUserId = it.style === 'sent' ? bossInfo.encryptBossId: it.style === 'received' ? currentUserInfo.encryptUserId : '' + mappedItem.encryptFromUserId = it.isSelf ? currentUserInfo.encryptUserId : bossInfo.encryptBossId + mappedItem.encryptToUserId = it.isSelf ? bossInfo.encryptBossId : currentUserInfo.encryptUserId mappedItem.style = it.style mappedItem.type = it.type mappedItem.time = it.time ? new Date(it.time) : null diff --git a/packages/ui/src/main/flow/READ_NO_REPLY_AUTO_REMINDER/index.ts b/packages/ui/src/main/flow/READ_NO_REPLY_AUTO_REMINDER/index.ts index b4f1824..8f70f77 100644 --- a/packages/ui/src/main/flow/READ_NO_REPLY_AUTO_REMINDER/index.ts +++ b/packages/ui/src/main/flow/READ_NO_REPLY_AUTO_REMINDER/index.ts @@ -31,7 +31,7 @@ async function saveCurrentChatRecord(page) { 'document.querySelector(".main-wrap").__vue__.$store.state.userInfo' ) const bossInfo = await page.evaluate( - 'document.querySelector(".chat-conversation").__vue__.bossInfo$' + 'document.querySelector(".chat-conversation .chat-record")?.__vue__?.boss' ) const ds = await dbInitPromise @@ -252,27 +252,34 @@ const mainLoop = async () => { }) } await sleepWithRandomDelay(1500) - const bossInfo = await pageMapByName.boss?.evaluate(() => { - return document.querySelector('.chat-conversation')?.__vue__['bossInfo$'] - }) + const bossInfo = await pageMapByName.boss?.evaluate( + 'document.querySelector(".chat-conversation .chat-record")?.__vue__?.boss' + ) const historyMessageList = ( await pageMapByName.boss?.evaluate(() => { - return ( - document.querySelector('.main-wrap .chat-conversation .chat-record')?.__vue__ - ?.records$ ?? [] - ) + return document.querySelector('.message-content .chat-record')?.__vue__?.list$ ?? [] }) - )?.filter((msg) => ['received', 'sent'].includes(msg.style)) ?? [] + )?.filter((it) => { + return ( + it.status !== 3 && // filter system notification out + it.templateId === 1 && // filter system notification out + ((['text', 'sticker', 'image', 'sound', 'comDesc'].includes(it.messageType) && + !it.extend?.greetingQuestionAnswer) || // include those message, filter out auto ask + (it.messageType === 'dialog' && + [0, 1, 2, 8, 11, 12, 14, 17, 33].includes(it?.dialog?.type))) // include message like resume, phone, map, etc., filter out auto ask + ) + }) ?? [] - const lastGeekMessageSendTime = - historyMessageList.findLast((it) => it.style === 'sent')?.time ?? 0 + const lastGeekMessageSendTime = historyMessageList.findLast((it) => it.isSelf)?.time ?? 0 if ( - historyMessageList[historyMessageList.length - 1].style === 'sent' && + historyMessageList[historyMessageList.length - 1].isSelf && historyMessageList[historyMessageList.length - 1].status === MsgStatus.HAS_READ && - (!bossInfo.bothTalked || - !historyMessageList.filter((it) => it.style === 'received').length) && + ((bossInfo && !bossInfo.bothTalked) || + !historyMessageList.filter( + (it) => !it.isSelf // not sent by me + ).length) && // don't disturb too much Date.now() - lastGeekMessageSendTime >= (throttleIntervalMinutes + 4 * Math.random()) * 60 * 1000