Merge branch 'feature/ui' into feature/aigc

This commit is contained in:
geekgeekrun
2025-04-06 00:27:01 +08:00
6 changed files with 41 additions and 27 deletions

View File

@@ -146,7 +146,7 @@ async function markJobAsNotSuitInRecommendPage (reasonCode) {
}
case MarkAsNotSuitReason.JOB_NOT_SUIT:
default: {
const jobNotSuitOptionProxy = await chooseReasonDialogProxy.$(`.zp-type-item[title="面试过/入职过"]`)
const jobNotSuitOptionProxy = (await chooseReasonDialogProxy.$(`.zp-type-item[title$="职位"]`)) ?? (await chooseReasonDialogProxy.$(`.zp-type-item[title="面试过/入职过"]`))
if (jobNotSuitOptionProxy) {
await jobNotSuitOptionProxy.click()
isOptionChosen = true

View File

@@ -1,6 +1,6 @@
{
"name": "geekgeekrun-ui",
"version": "0.3.0",
"version": "0.3.2",
"description": "Boss 炸弹 - 自动开聊Boss助力每位打工人求职",
"main": "./out/main/index.js",
"author": "geekgeekrun",

View File

@@ -1,7 +1,7 @@
{
"version": "0.3.0",
"buildVersion": 6,
"buildTime": 1735446486022,
"buildHash": "6f8dab0c0550b594de1d23f92f21a5194b0c8b62",
"version": "0.3.2",
"buildVersion": 8,
"buildTime": 1743435647129,
"buildHash": "482ea006be25bc7014793c09cc748fae6606e27e",
"name": "geekgeekrun-ui"
}

View File

@@ -0,0 +1,9 @@
export function messageForSaveFilter(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
)
}

View File

@@ -29,6 +29,7 @@ import gtag from '../../utils/gtag'
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
import { type ChatMessageRecord } from '@geekgeekrun/sqlite-plugin/src/entity/ChatMessageRecord'
import { BossInfo } from '@geekgeekrun/sqlite-plugin/dist/entity/BossInfo'
import { messageForSaveFilter } from '../../../common/utils/chat-list'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
@@ -181,9 +182,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 +212,15 @@ 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(messageForSaveFilter) ?? []
const chatRecordList = rawChatRecordList.map(it => {
const mappedItem = {} as InstanceType<typeof ChatMessageRecord>
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

View File

@@ -16,6 +16,7 @@ import { writeStorageFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/ru
import * as fs from 'fs'
import { pipeWriteRegardlessError } from '../utils/pipe'
import { BossInfo } from '@geekgeekrun/sqlite-plugin/dist/entity/BossInfo'
import { messageForSaveFilter } from '../../../common/utils/chat-list'
const throttleIntervalMinutes =
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
@@ -31,7 +32,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 +253,25 @@ 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(messageForSaveFilter) ?? []
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