extract messageForSaveFilter

This commit is contained in:
geekgeekrun
2025-04-05 03:41:52 +08:00
parent acd8227740
commit 7ee8baa311
3 changed files with 13 additions and 20 deletions

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)
@@ -213,16 +214,7 @@ const attachRequestsListener = async (target: Target) => {
await page.evaluate(
'document.querySelector(".message-content .chat-record").__vue__.list$'
)
)?.filter((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
)
)
}) ?? []
)?.filter(messageForSaveFilter) ?? []
const chatRecordList = rawChatRecordList.map(it => {
const mappedItem = {} as InstanceType<typeof ChatMessageRecord>

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
@@ -261,16 +262,7 @@ const mainLoop = async () => {
await pageMapByName.boss?.evaluate(() => {
return document.querySelector('.message-content .chat-record')?.__vue__?.list$ ?? []
})
)?.filter((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
)
}) ?? []
)?.filter(messageForSaveFilter) ?? []
const lastGeekMessageSendTime = historyMessageList.findLast((it) => it.isSelf)?.time ?? 0
if (