mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-09 01:17:06 +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
|
pageMapByName['boss'] = null
|
||||||
const cp = browser.process()
|
const cp = browser.process()
|
||||||
cp?.kill()
|
cp?.kill()
|
||||||
process.exit(0)
|
|
||||||
})
|
})
|
||||||
return page
|
return page
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,26 @@
|
|||||||
import { bootstrap, launchBoss } from './bootstrap'
|
import { bootstrap, launchBoss } from './bootstrap'
|
||||||
import { MsgStatus, type ChatListItem } from './types'
|
import { MsgStatus, type ChatListItem } from './types'
|
||||||
import { Page } from 'puppeteer'
|
import { Browser, Page } from 'puppeteer'
|
||||||
import { sendLookForwardReplyEmotion } from './boss-operation'
|
import { sendLookForwardReplyEmotion } from './boss-operation'
|
||||||
import { sleep, sleepWithRandomDelay } from '@geekgeekrun/utils/sleep.mjs'
|
import { sleep, sleepWithRandomDelay } from '@geekgeekrun/utils/sleep.mjs'
|
||||||
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
||||||
|
import { app } from 'electron'
|
||||||
|
|
||||||
export const pageMapByName: {
|
export const pageMapByName: {
|
||||||
boss?: Page | null
|
boss?: Page | null
|
||||||
} = {}
|
} = {}
|
||||||
|
|
||||||
export const runEntry = async () => {
|
let browser: null | Browser = null
|
||||||
|
const mainLoop = async () => {
|
||||||
|
if (browser) {
|
||||||
try {
|
try {
|
||||||
|
await browser?.close()
|
||||||
|
} catch {
|
||||||
|
//
|
||||||
|
} finally {
|
||||||
|
browser = null
|
||||||
|
}
|
||||||
|
}
|
||||||
const canNotConfirmIfHasReadMsgTemplateList = [
|
const canNotConfirmIfHasReadMsgTemplateList = [
|
||||||
'Boss还没查看你的消息',
|
'Boss还没查看你的消息',
|
||||||
'你与该职位竞争者PK情况',
|
'你与该职位竞争者PK情况',
|
||||||
@@ -18,7 +28,7 @@ export const runEntry = async () => {
|
|||||||
'附件简历还没准备好',
|
'附件简历还没准备好',
|
||||||
'开场问题,期待你的回答'
|
'开场问题,期待你的回答'
|
||||||
].map((it) => new RegExp(it))
|
].map((it) => new RegExp(it))
|
||||||
const browser = await bootstrap()
|
browser = await bootstrap()
|
||||||
await Promise.all([launchBoss(browser)])
|
await Promise.all([launchBoss(browser)])
|
||||||
|
|
||||||
await sleep(1000)
|
await sleep(1000)
|
||||||
@@ -153,9 +163,38 @@ export const runEntry = async () => {
|
|||||||
}
|
}
|
||||||
await sleep(3000)
|
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) {
|
} catch (err) {
|
||||||
console.error(err)
|
await browser?.close()
|
||||||
|
} finally {
|
||||||
|
browser = null
|
||||||
|
await sleep(rerunInterval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
attachListenerForKillSelfOnParentExited()
|
attachListenerForKillSelfOnParentExited()
|
||||||
|
|||||||
Reference in New Issue
Block a user