mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-08 17:09:07 +08:00
add the rerun logic for read no reply auto reminder
This commit is contained in:
@@ -39,7 +39,6 @@ export async function launchBoss(browser: Browser) {
|
||||
pageMapByName['boss'] = null
|
||||
const cp = browser.process()
|
||||
cp?.kill()
|
||||
process.exit(0)
|
||||
})
|
||||
return page
|
||||
}
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
import { bootstrap, launchBoss } from './bootstrap'
|
||||
import { MsgStatus, type ChatListItem } from './types'
|
||||
import { Page } from 'puppeteer'
|
||||
import { Browser, Page } from 'puppeteer'
|
||||
import { sendLookForwardReplyEmotion } from './boss-operation'
|
||||
import { sleep, sleepWithRandomDelay } from '@geekgeekrun/utils/sleep.mjs'
|
||||
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
||||
import { app } from 'electron'
|
||||
|
||||
export const pageMapByName: {
|
||||
boss?: Page | null
|
||||
} = {}
|
||||
|
||||
export const runEntry = async () => {
|
||||
let browser: null | Browser = null
|
||||
const mainLoop = async () => {
|
||||
if (browser) {
|
||||
try {
|
||||
await browser?.close()
|
||||
} catch {
|
||||
//
|
||||
} finally {
|
||||
browser = null
|
||||
}
|
||||
}
|
||||
const canNotConfirmIfHasReadMsgTemplateList = [
|
||||
'Boss还没查看你的消息',
|
||||
'你与该职位竞争者PK情况',
|
||||
@@ -18,7 +28,7 @@ export const runEntry = async () => {
|
||||
'附件简历还没准备好',
|
||||
'开场问题,期待你的回答'
|
||||
].map((it) => new RegExp(it))
|
||||
const browser = await bootstrap()
|
||||
browser = await bootstrap()
|
||||
await Promise.all([launchBoss(browser)])
|
||||
|
||||
await sleep(1000)
|
||||
@@ -153,9 +163,38 @@ export const runEntry = async () => {
|
||||
}
|
||||
await sleep(3000)
|
||||
}
|
||||
}
|
||||
|
||||
let isParentProcessDisconnect = false
|
||||
process.once('disconnect', () => {
|
||||
isParentProcessDisconnect = true
|
||||
})
|
||||
const rerunInterval = (() => {
|
||||
let v = Number(process.env.MAIN_BOSSGEEKGO_RERUN_INTERVAL)
|
||||
if (isNaN(v)) {
|
||||
v = 3000
|
||||
}
|
||||
|
||||
return v
|
||||
})()
|
||||
export async function runEntry() {
|
||||
process.on('disconnect', () => {
|
||||
app.exit()
|
||||
})
|
||||
app.dock?.hide()
|
||||
|
||||
while (!isParentProcessDisconnect) {
|
||||
try {
|
||||
await mainLoop()
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
await browser?.close()
|
||||
} finally {
|
||||
browser = null
|
||||
await sleep(rerunInterval)
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
attachListenerForKillSelfOnParentExited()
|
||||
|
||||
Reference in New Issue
Block a user