mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-07-12 07:52:18 +08:00
extract messageForSaveFilter
This commit is contained in:
9
packages/ui/src/common/utils/chat-list.ts
Normal file
9
packages/ui/src/common/utils/chat-list.ts
Normal 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
|
||||
)
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user