mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 08:27:13 +08:00
add throttleIntervalMinutes config field for auto reminder
This commit is contained in:
@@ -6,5 +6,8 @@
|
|||||||
"scaleList": [],
|
"scaleList": [],
|
||||||
"industryList": []
|
"industryList": []
|
||||||
},
|
},
|
||||||
"expectJobRegExpStr": ""
|
"expectJobRegExpStr": "",
|
||||||
|
"autoReminder": {
|
||||||
|
"throttleIntervalMinutes": 10
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,8 @@ import {
|
|||||||
import { PageReq } from '../../../../common/types/pagination'
|
import { PageReq } from '../../../../common/types/pagination'
|
||||||
import { pipeWriteRegardlessError } from '../../utils/pipe'
|
import { pipeWriteRegardlessError } from '../../utils/pipe'
|
||||||
import { WriteStream } from 'node:fs'
|
import { WriteStream } from 'node:fs'
|
||||||
|
// eslint-disable-next-line vue/prefer-import-from-vue
|
||||||
|
import { hasOwn } from '@vue/shared'
|
||||||
|
|
||||||
export default function initIpc() {
|
export default function initIpc() {
|
||||||
ipcMain.on('open-external-link', (_, link) => {
|
ipcMain.on('open-external-link', (_, link) => {
|
||||||
@@ -55,18 +57,33 @@ export default function initIpc() {
|
|||||||
payload = JSON.parse(payload)
|
payload = JSON.parse(payload)
|
||||||
ensureConfigFileExist()
|
ensureConfigFileExist()
|
||||||
|
|
||||||
|
const promiseArr: Array<Promise<unknown>> = []
|
||||||
|
|
||||||
const dingtalkConfig = readConfigFile('dingtalk.json')
|
const dingtalkConfig = readConfigFile('dingtalk.json')
|
||||||
dingtalkConfig.groupRobotAccessToken = payload.dingtalkRobotAccessToken
|
if (hasOwn(payload, 'dingtalkRobotAccessToken')) {
|
||||||
|
dingtalkConfig.groupRobotAccessToken = payload.dingtalkRobotAccessToken
|
||||||
|
}
|
||||||
|
promiseArr.push(writeConfigFile('dingtalk.json', dingtalkConfig))
|
||||||
|
|
||||||
const bossConfig = readConfigFile('boss.json')
|
const bossConfig = readConfigFile('boss.json')
|
||||||
bossConfig.anyCombineRecommendJobFilter = payload.anyCombineRecommendJobFilter
|
if (hasOwn(payload, 'anyCombineRecommendJobFilter')) {
|
||||||
bossConfig.expectJobRegExpStr = payload.expectJobRegExpStr
|
bossConfig.anyCombineRecommendJobFilter = payload.anyCombineRecommendJobFilter
|
||||||
|
}
|
||||||
|
if (hasOwn(payload, 'expectJobRegExpStr')) {
|
||||||
|
bossConfig.expectJobRegExpStr = payload.expectJobRegExpStr
|
||||||
|
}
|
||||||
|
if (hasOwn(payload, 'autoReminder')) {
|
||||||
|
bossConfig.autoReminder = payload.autoReminder
|
||||||
|
}
|
||||||
|
promiseArr.push(writeConfigFile('boss.json', bossConfig))
|
||||||
|
|
||||||
return await Promise.all([
|
if (hasOwn(payload, 'expectCompanies')) {
|
||||||
writeConfigFile('dingtalk.json', dingtalkConfig),
|
promiseArr.push(
|
||||||
writeConfigFile('target-company-list.json', payload.expectCompanies.split(',')),
|
writeConfigFile('target-company-list.json', payload.expectCompanies?.split(',') ?? [])
|
||||||
writeConfigFile('boss.json', bossConfig)
|
)
|
||||||
])
|
}
|
||||||
|
|
||||||
|
return await Promise.all(promiseArr)
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.handle('read-storage-file', async (ev, payload) => {
|
ipcMain.handle('read-storage-file', async (ev, payload) => {
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import { sleep, sleepWithRandomDelay } from '@geekgeekrun/utils/sleep.mjs'
|
|||||||
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
||||||
import { app } from 'electron'
|
import { app } from 'electron'
|
||||||
import { initDb } from '@geekgeekrun/sqlite-plugin'
|
import { initDb } from '@geekgeekrun/sqlite-plugin'
|
||||||
import { getPublicDbFilePath } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
import {
|
||||||
|
getPublicDbFilePath,
|
||||||
|
readConfigFile
|
||||||
|
} from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||||
import { ChatMessageRecord } from '@geekgeekrun/sqlite-plugin/dist/entity/ChatMessageRecord'
|
import { ChatMessageRecord } from '@geekgeekrun/sqlite-plugin/dist/entity/ChatMessageRecord'
|
||||||
import { saveChatMessageRecord } from '@geekgeekrun/sqlite-plugin/dist/handlers'
|
import { saveChatMessageRecord } from '@geekgeekrun/sqlite-plugin/dist/handlers'
|
||||||
import { writeStorageFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
import { writeStorageFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||||
@@ -14,6 +17,8 @@ import * as fs from 'fs'
|
|||||||
import { pipeWriteRegardlessError } from '../utils/pipe'
|
import { pipeWriteRegardlessError } from '../utils/pipe'
|
||||||
import { BossInfo } from '@geekgeekrun/sqlite-plugin/dist/entity/BossInfo'
|
import { BossInfo } from '@geekgeekrun/sqlite-plugin/dist/entity/BossInfo'
|
||||||
|
|
||||||
|
const throttleIntervalMinutes =
|
||||||
|
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
|
||||||
const dbInitPromise = initDb(getPublicDbFilePath())
|
const dbInitPromise = initDb(getPublicDbFilePath())
|
||||||
|
|
||||||
export const pageMapByName: {
|
export const pageMapByName: {
|
||||||
@@ -263,7 +268,8 @@ const mainLoop = async () => {
|
|||||||
(!bossInfo.bothTalked ||
|
(!bossInfo.bothTalked ||
|
||||||
!historyMessageList.filter((it) => it.style === 'received').length) &&
|
!historyMessageList.filter((it) => it.style === 'received').length) &&
|
||||||
// don't disturb too much
|
// don't disturb too much
|
||||||
Date.now() - lastGeekMessageSendTime >= 8 * 60 * 60 * 1000
|
Date.now() - lastGeekMessageSendTime >=
|
||||||
|
(throttleIntervalMinutes + 4 * Math.random()) * 60 * 1000
|
||||||
) {
|
) {
|
||||||
await sleepWithRandomDelay(3250)
|
await sleepWithRandomDelay(3250)
|
||||||
await sendLookForwardReplyEmotion(pageMapByName.boss!)
|
await sendLookForwardReplyEmotion(pageMapByName.boss!)
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="form-wrap">
|
<div class="form-wrap">
|
||||||
<el-form ref="formRef" label-position="top" :rules="formRules">
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:rules="formRules"
|
||||||
|
:model="formContent.autoReminder"
|
||||||
|
label-position="top"
|
||||||
|
>
|
||||||
<el-form-item label="BOSS直聘 Cookie">
|
<el-form-item label="BOSS直聘 Cookie">
|
||||||
<el-button size="small" type="primary" font-size-inherit @click="handleClickLaunchLogin"
|
<el-button size="small" type="primary" font-size-inherit @click="handleClickLaunchLogin"
|
||||||
>编辑Cookie</el-button
|
>编辑Cookie</el-button
|
||||||
@@ -9,8 +14,13 @@
|
|||||||
<el-form-item label="复聊话术" class="color-orange">
|
<el-form-item label="复聊话术" class="color-orange">
|
||||||
当发现已读不回的Boss时,将向Boss发出“[盼回复]”表情
|
当发现已读不回的Boss时,将向Boss发出“[盼回复]”表情
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="复聊间隔" class="color-orange">
|
<el-form-item label="复聊间隔" prop="throttleIntervalMinutes">
|
||||||
8小时内不向同一Boss多次复聊
|
<el-input
|
||||||
|
v-model="formContent.autoReminder.throttleIntervalMinutes"
|
||||||
|
class="w-100px"
|
||||||
|
min="3"
|
||||||
|
@blur="handleThrottleIntervalMinutesBlur"
|
||||||
|
/> 分钟内不向同一Boss多次复聊
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item class="last-form-item">
|
<el-form-item class="last-form-item">
|
||||||
<el-button type="primary" @click="handleSubmit">开始提醒</el-button>
|
<el-button type="primary" @click="handleSubmit">开始提醒</el-button>
|
||||||
@@ -25,18 +35,48 @@ import { ElForm } from 'element-plus'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
electron.ipcRenderer.invoke('fetch-config-file-content').then((res) => {})
|
const formContent = ref({
|
||||||
|
autoReminder: {
|
||||||
|
throttleIntervalMinutes: 10
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const formRules = {}
|
electron.ipcRenderer.invoke('fetch-config-file-content').then((res) => {
|
||||||
|
formContent.value.autoReminder = res.config['boss.json']?.autoReminder ?? {
|
||||||
|
throttleIntervalMinutes: 10
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const formRules = {
|
||||||
|
throttleIntervalMinutes: {
|
||||||
|
trigger: 'blur',
|
||||||
|
validator (_, value, cb) {
|
||||||
|
if (/[^0-9.]/.test(String(value)) || isNaN(parseFloat(value)) || isNaN(Number(value))) {
|
||||||
|
cb(new Error(`请输入数字!`))
|
||||||
|
} else {
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const formRef = ref<InstanceType<typeof ElForm>>()
|
const formRef = ref<InstanceType<typeof ElForm>>()
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
await formRef.value!.validate()
|
await formRef.value!.validate()
|
||||||
|
await electron.ipcRenderer.invoke('save-config-file-from-ui', JSON.stringify(formContent.value))
|
||||||
router.replace({
|
router.replace({
|
||||||
path: '/geekAutoStartChatWithBoss/prepareRun',
|
path: '/geekAutoStartChatWithBoss/prepareRun',
|
||||||
query: { flow: 'read-no-reply-reminder' }
|
query: { flow: 'read-no-reply-reminder' }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function handleThrottleIntervalMinutesBlur () {
|
||||||
|
if (formContent.value.autoReminder.throttleIntervalMinutes < 3) {
|
||||||
|
formContent.value.autoReminder.throttleIntervalMinutes = 3
|
||||||
|
}
|
||||||
|
formContent.value.autoReminder.throttleIntervalMinutes = Number(
|
||||||
|
formContent.value.autoReminder.throttleIntervalMinutes
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const handleClickLaunchLogin = () => {
|
const handleClickLaunchLogin = () => {
|
||||||
router.replace('/cookieAssistant')
|
router.replace('/cookieAssistant')
|
||||||
|
|||||||
Reference in New Issue
Block a user