mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-08 00:47:15 +08:00
extract messageForSaveFilter
This commit is contained in:
@@ -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
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -29,6 +29,7 @@ import gtag from '../../utils/gtag'
|
|||||||
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
||||||
import { type ChatMessageRecord } from '@geekgeekrun/sqlite-plugin/src/entity/ChatMessageRecord'
|
import { type ChatMessageRecord } from '@geekgeekrun/sqlite-plugin/src/entity/ChatMessageRecord'
|
||||||
import { BossInfo } from '@geekgeekrun/sqlite-plugin/dist/entity/BossInfo'
|
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 __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||||
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
||||||
@@ -213,16 +214,7 @@ const attachRequestsListener = async (target: Target) => {
|
|||||||
await page.evaluate(
|
await page.evaluate(
|
||||||
'document.querySelector(".message-content .chat-record").__vue__.list$'
|
'document.querySelector(".message-content .chat-record").__vue__.list$'
|
||||||
)
|
)
|
||||||
)?.filter((it) => {
|
)?.filter(messageForSaveFilter) ?? []
|
||||||
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 chatRecordList = rawChatRecordList.map(it => {
|
||||||
const mappedItem = {} as InstanceType<typeof ChatMessageRecord>
|
const mappedItem = {} as InstanceType<typeof ChatMessageRecord>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { writeStorageFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/ru
|
|||||||
import * as fs from 'fs'
|
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'
|
||||||
|
import { messageForSaveFilter } from '../../../common/utils/chat-list'
|
||||||
|
|
||||||
const throttleIntervalMinutes =
|
const throttleIntervalMinutes =
|
||||||
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
|
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
|
||||||
@@ -261,16 +262,7 @@ const mainLoop = async () => {
|
|||||||
await pageMapByName.boss?.evaluate(() => {
|
await pageMapByName.boss?.evaluate(() => {
|
||||||
return document.querySelector('.message-content .chat-record')?.__vue__?.list$ ?? []
|
return document.querySelector('.message-content .chat-record')?.__vue__?.list$ ?? []
|
||||||
})
|
})
|
||||||
)?.filter((it) => {
|
)?.filter(messageForSaveFilter) ?? []
|
||||||
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.isSelf)?.time ?? 0
|
const lastGeekMessageSendTime = historyMessageList.findLast((it) => it.isSelf)?.time ?? 0
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user