diff --git a/packages/koishi-core/src/meta.ts b/packages/koishi-core/src/meta.ts index 941c2b682e..b0f32b16e4 100644 --- a/packages/koishi-core/src/meta.ts +++ b/packages/koishi-core/src/meta.ts @@ -1,4 +1,4 @@ -import { User, Group, UserField, GroupField } from './database' +import { User, Group } from './database' import { ParsedCommandLine } from './command' import { isInteger } from 'koishi-utils' diff --git a/packages/koishi-utils/src/observe.ts b/packages/koishi-utils/src/observe.ts index ba1ae0e17a..b6b5d9dbee 100644 --- a/packages/koishi-utils/src/observe.ts +++ b/packages/koishi-utils/src/observe.ts @@ -8,13 +8,12 @@ const builtinClasses = ['Date', 'RegExp', 'Set', 'Map', 'WeakSet', 'WeakMap', 'A const refs: Record = {} function observeObject (target: T, label: string, update?: () => void): T { - Object.defineProperty(target, '__proxyGetters__', { value: {} }) + if (!target['__proxyGetters__']) { + Object.defineProperty(target, '__proxyGetters__', { value: {} }) + } if (!update) { - Object.defineProperty(target, '_diff', { - value: {}, - writable: true, - }) + Object.defineProperty(target, '_diff', { value: {}, writable: true }) } return new Proxy(target as Observed, { diff --git a/packages/plugin-teach/src/internal.ts b/packages/plugin-teach/src/internal.ts index 4ba17941c8..b53e3cbe80 100644 --- a/packages/plugin-teach/src/internal.ts +++ b/packages/plugin-teach/src/internal.ts @@ -1,6 +1,35 @@ import { Context } from 'koishi-core' import { DialogueFlag } from './database' -import { simplifyQuestion, simplifyAnswer } from './utils' +import { simplify } from 'koishi-utils' + +const prefixPunctuation = /^([()\]]|\[(?!cq:))*/ +const suffixPunctuation = /([.,?!()[~]|(? { if (meta.message.includes('[CQ:image,')) return true test.question = simplifyQuestion(meta.message) + return !test.question }) } diff --git a/packages/plugin-teach/src/receiver.ts b/packages/plugin-teach/src/receiver.ts index 0cbd93d162..dbd13f32c5 100644 --- a/packages/plugin-teach/src/receiver.ts +++ b/packages/plugin-teach/src/receiver.ts @@ -1,6 +1,6 @@ import { Context, UserField, getSenderName, Meta } from 'koishi-core' import { CQCode, sleep } from 'koishi-utils' -import { simplifyQuestion, getDialogues } from './utils' +import { getDialogues } from './utils' import { Dialogue, DialogueTest } from './database' declare module 'koishi-core/dist/context' { diff --git a/packages/plugin-teach/src/utils.ts b/packages/plugin-teach/src/utils.ts index 1e010d96bc..2b094991dd 100644 --- a/packages/plugin-teach/src/utils.ts +++ b/packages/plugin-teach/src/utils.ts @@ -1,5 +1,5 @@ import { Context, Meta, User } from 'koishi-core' -import { simplify, difference } from 'koishi-utils' +import { difference } from 'koishi-utils' import { Dialogue, DialogueTest } from './database' import { SessionState } from './receiver' @@ -17,40 +17,7 @@ declare module 'koishi-core/dist/context' { } } -export interface TeachConfig { - key?: string - imageServer?: string - uploadServer?: string -} - -const prefixPunctuation = /^([()\]]|\[(?!cq:))*/ -const suffixPunctuation = /([.,?!()[~]|(? (array: T[]) { return [...new Set(array)]