diff --git a/packages/core/package.json b/packages/core/package.json index 6bb0118154..96dcbd07c5 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -36,7 +36,7 @@ }, "dependencies": { "@koishijs/utils": "^5.4.4", - "cordis": "^1.0.0", + "cordis": "^1.1.1", "fastest-levenshtein": "^1.0.12", "minato": "^1.1.0" } diff --git a/packages/utils/package.json b/packages/utils/package.json index bfaf8130de..283e9cd226 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -33,7 +33,7 @@ "@koishijs/segment": "^1.1.1", "cosmokit": "^1.1.2", "reggol": "^1.0.3", - "schemastery": "^3.4.1", + "schemastery": "^3.4.2", "supports-color": "^8.1.1" } } \ No newline at end of file diff --git a/plugins/a11y/schedule/tests/index.spec.ts b/plugins/a11y/schedule/tests/index.spec.ts index e5a58f6676..e8880e3073 100644 --- a/plugins/a11y/schedule/tests/index.spec.ts +++ b/plugins/a11y/schedule/tests/index.spec.ts @@ -85,7 +85,7 @@ describe('Schedule Plugin', () => { await new Promise(process.nextTick) await client1.shouldReply('', 'foo') - await client1.shouldReply('schedule -l', '2. 2000-01-01 00:30:00 起每隔 1 小时:echo foo') + await client1.shouldReply('schedule -l', '2. 每隔 1 小时 (剩余 59 分钟):echo foo') await client1.shouldReply('schedule -d 2', '日程 2 已删除。') clock.tick(Time.hour) // 02:31 await new Promise(process.nextTick) diff --git a/plugins/common/echo/tests/index.spec.ts b/plugins/common/echo/tests/index.spec.ts index a811f177f6..58cf546c47 100644 --- a/plugins/common/echo/tests/index.spec.ts +++ b/plugins/common/echo/tests/index.spec.ts @@ -18,7 +18,7 @@ describe('@koishijs/plugin-echo', () => { it('basic support', async () => { await client.shouldReply('echo', '请输入要发送的文本。') await client.shouldReply('echo foo', 'foo') - await client.shouldReply('echo -e []', '[]') + await client.shouldReply('echo -E []', '[]') await client.shouldReply('echo -A foo', '[CQ:anonymous]foo') await client.shouldReply('echo -a foo', '[CQ:anonymous,ignore=true]foo') diff --git a/plugins/common/forward/src/index.ts b/plugins/common/forward/src/index.ts index c26f1d9af3..338ff60c0a 100644 --- a/plugins/common/forward/src/index.ts +++ b/plugins/common/forward/src/index.ts @@ -14,7 +14,7 @@ export interface Rule { guildId?: string } -export const Rule = Schema.object({ +export const Rule: Schema = Schema.object({ source: Schema.string().required().description('来源频道'), target: Schema.string().required().description('目标频道'), selfId: Schema.string().required().description('负责推送的机器人账号'), @@ -28,12 +28,12 @@ export interface Config { interval?: number } -export const schema = Schema.union([ +export const Config = Schema.union([ Schema.object({ rules: Schema.array(Rule).description('转发规则'), interval: Schema.natural().role('ms').default(Time.hour).description('推送消息不再响应回复的时间。'), }), - Schema.transform(Schema.array(Rule), (rules) => ({ rules })), + Schema.transform(Schema.array(Rule), (rules) => ({ rules, interval: Time.hour })), ]) export function apply(ctx: Context, { rules, interval }: Config) { diff --git a/plugins/common/forward/tests/index.spec.ts b/plugins/common/forward/tests/index.spec.ts index 6822d6048a..02db894f14 100644 --- a/plugins/common/forward/tests/index.spec.ts +++ b/plugins/common/forward/tests/index.spec.ts @@ -47,7 +47,7 @@ describe('@koishijs/plugin-forward', () => { it('command usage', async () => { app.plugin('database-memory') - await app._tasks.flush() + await app.lifecycle.flush() await app.mock.initUser('123', 3) await session2.shouldReply('forward', /设置消息转发/) diff --git a/plugins/common/repeater/tests/index.spec.ts b/plugins/common/repeater/tests/index.spec.ts index fbaf42d5c2..e91dc19fc5 100644 --- a/plugins/common/repeater/tests/index.spec.ts +++ b/plugins/common/repeater/tests/index.spec.ts @@ -2,57 +2,60 @@ import { App } from 'koishi' import mock from '@koishijs/plugin-mock' import * as repeater from '@koishijs/plugin-repeater' -const app = new App().plugin(mock) -const session1 = app.mock.client('123', '123') -const session2 = app.mock.client('456', '123') -const session3 = app.mock.client('789', '123') +async function setup(config: repeater.Config) { + const app = new App().plugin(mock) + const client1 = app.mock.client('123', '123') + const client2 = app.mock.client('456', '123') + const client3 = app.mock.client('789', '123') -const options: repeater.Config = {} -app.plugin(repeater, options) - -before(() => app.start()) + app.plugin(repeater, config) + await app.start() + return [client1, client2, client3] +} describe('Repeater', () => { - beforeEach(async () => { - options.onRepeat = null - options.onInterrupt = null - await session1.shouldNotReply('clear') - }) - it('repeat (basic config)', async () => { - options.onRepeat = { minTimes: 2 } - - await session1.shouldNotReply('foo') - await session1.shouldReply('foo', 'foo') - await session1.shouldNotReply('foo') - await session1.shouldNotReply('foo') + const [client1] = await setup({ + onRepeat: { minTimes: 2 }, + }) + + await client1.shouldNotReply('foo') + await client1.shouldReply('foo', 'foo') + await client1.shouldNotReply('foo') + await client1.shouldNotReply('foo') }) it('repeat check', async () => { - options.onRepeat = ({ users }, { userId }) => users[userId] > 2 ? '在?为什么重复复读?' : '' - - await session1.shouldNotReply('foo') - await session2.shouldNotReply('foo') - await session3.shouldNotReply('foo') - await session1.shouldNotReply('foo') - await session1.shouldReply('foo', '在?为什么重复复读?') + const [client1, client2, client3] = await setup({ + onRepeat: ({ users }, { userId }) => users[userId] > 2 ? '在?为什么重复复读?' : '', + }) + + await client1.shouldNotReply('foo') + await client2.shouldNotReply('foo') + await client3.shouldNotReply('foo') + await client1.shouldNotReply('foo') + await client1.shouldReply('foo', '在?为什么重复复读?') }) it('interrupt', async () => { - options.onRepeat = ({ times }) => times >= 3 ? '打断复读!' : '' + const [client1, client2, client3] = await setup({ + onRepeat: ({ times }) => times >= 3 ? '打断复读!' : '', + }) - await session1.shouldNotReply('foo') - await session2.shouldNotReply('foo') - await session3.shouldReply('foo', '打断复读!') + await client1.shouldNotReply('foo') + await client2.shouldNotReply('foo') + await client3.shouldReply('foo', '打断复读!') }) it('interrupt check', async () => { - options.onInterrupt = ({ times }) => times >= 2 ? '在?为什么打断复读?' : '' - - await session1.shouldNotReply('foo') - await session2.shouldNotReply('bar') - await session1.shouldNotReply('foo') - await session2.shouldNotReply('foo') - await session3.shouldReply('bar', '在?为什么打断复读?') + const [client1, client2, client3] = await setup({ + onInterrupt: ({ times }) => times >= 2 ? '在?为什么打断复读?' : '', + }) + + await client1.shouldNotReply('foo') + await client2.shouldNotReply('bar') + await client1.shouldNotReply('foo') + await client2.shouldNotReply('foo') + await client3.shouldReply('bar', '在?为什么打断复读?') }) }) diff --git a/plugins/frontend/client/package.json b/plugins/frontend/client/package.json index 4212201e26..7de431b299 100644 --- a/plugins/frontend/client/package.json +++ b/plugins/frontend/client/package.json @@ -43,7 +43,7 @@ "element-plus": "^2.1.11", "marked": "^4.0.15", "sass": "^1.51.0", - "schemastery": "^3.4.1", + "schemastery": "^3.4.2", "vite": "^2.9.8", "vue": "^3.2.33", "vue-router": "^4.0.14"