diff --git a/packages/core/src/locales/zh-CN.yml b/packages/core/src/locales/zh-CN.yml index 3cf0e587e..06e928fca 100644 --- a/packages/core/src/locales/zh-CN.yml +++ b/packages/core/src/locales/zh-CN.yml @@ -30,7 +30,7 @@ internal: invalid-user: 请指定正确的用户。 invalid-channel: 请指定正确的频道。 suggest-hint: 您要找的是不是{0}? - suggest-command: 发送句号以使用推测的指令。 + suggest-command: 回复句号以使用推测的指令。 commands: $: 指令系统 diff --git a/packages/core/src/session.ts b/packages/core/src/session.ts index ea41f0dd6..cf7f8feaa 100644 --- a/packages/core/src/session.ts +++ b/packages/core/src/session.ts @@ -471,8 +471,9 @@ export class Session { - const content = session.content.trim() - if (!content || content === '.' || content === '。') { + const { content, atSelf, hasAt } = session.stripped + if (!atSelf && hasAt) return + if (content === '.' || content === '。') { return expect[0] } }, options) diff --git a/packages/core/tests/suggest.spec.ts b/packages/core/tests/suggest.spec.ts index b3233468d..2ec54459f 100644 --- a/packages/core/tests/suggest.spec.ts +++ b/packages/core/tests/suggest.spec.ts @@ -21,7 +21,7 @@ describe('Command Suggestion', () => { it('execute command', async () => { await client1.shouldReply('foo bar', 'foobar') - await client1.shouldNotReply(' ') + await client1.shouldNotReply('.') }) it('no suggestions', async () => { @@ -29,34 +29,34 @@ describe('Command Suggestion', () => { }) it('apply suggestions 1', async () => { - await client1.shouldReply('fo bar', '您要找的是不是“foo”?发送句号以使用推测的指令。') + await client1.shouldReply('fo bar', '您要找的是不是“foo”?回复句号以使用推测的指令。') await client2.shouldReply('/fooo -t bar', 'fooobar') - await client1.shouldReply(' ', 'foobar') - await client1.shouldNotReply(' ') + await client1.shouldReply('.', 'foobar') + await client1.shouldNotReply('.') }) it('apply suggestions 2', async () => { - await client2.shouldReply('/foooo -t bar', '您要找的是不是“fooo”?发送句号以使用推测的指令。') + await client2.shouldReply('/foooo -t bar', '您要找的是不是“fooo”?回复句号以使用推测的指令。') await client1.shouldReply('foo bar', 'foobar') - await client2.shouldReply(' ', 'fooobar') - await client2.shouldNotReply(' ') + await client2.shouldReply('.', 'fooobar') + await client2.shouldNotReply('.') }) it('ignore suggestions 1', async () => { - await client1.shouldReply('fo bar', '您要找的是不是“foo”?发送句号以使用推测的指令。') + await client1.shouldReply('fo bar', '您要找的是不是“foo”?回复句号以使用推测的指令。') await client1.shouldNotReply('bar foo') - await client1.shouldNotReply(' ') + await client1.shouldNotReply('.') }) it('ignore suggestions 2', async () => { - await client2.shouldReply('/fo bar', '您要找的是不是“foo”?发送句号以使用推测的指令。') + await client2.shouldReply('/fo bar', '您要找的是不是“foo”?回复句号以使用推测的指令。') await client2.shouldReply('/foo bar', 'foobar') - await client2.shouldNotReply(' ') + await client2.shouldNotReply('.') }) it('multiple suggestions', async () => { await client1.shouldReply('fool bar', '您要找的是不是“foo”或“fooo”或“bool”?') - await client1.shouldNotReply(' ') + await client1.shouldNotReply('.') }) }) @@ -83,16 +83,16 @@ describe('session.suggest()', () => { after(() => app.stop()) it('no suggestions', async () => { - await client.shouldNotReply(' ') + await client.shouldNotReply('.') await client.shouldNotReply('find for') }) it('show suggestions', async () => { await client.shouldReply('.find 111', 'PREFIX') - await client.shouldNotReply(' ') + await client.shouldNotReply('.') await client.shouldReply('.find for', `PREFIX您要找的是不是“foo”?SUFFIX`) - await client.shouldReply(' ', 'found:foo') + await client.shouldReply('.', 'found:foo') await client.shouldReply('.find bax', `PREFIX您要找的是不是“bar”或“baz”?`) - await client.shouldNotReply(' ') + await client.shouldNotReply('.') }) }) diff --git a/plugins/common/help/tests/index.spec.ts b/plugins/common/help/tests/index.spec.ts index c3cbf2299..d49bee90f 100644 --- a/plugins/common/help/tests/index.spec.ts +++ b/plugins/common/help/tests/index.spec.ts @@ -42,7 +42,7 @@ describe('@koishijs/plugin-help', () => { ].join('\n')) await client.shouldReply('help xxxx', '指令未找到。') - await client.shouldReply('help heip', '指令未找到。您要找的是不是“help”?发送句号以使用推测的指令。') + await client.shouldReply('help heip', '指令未找到。您要找的是不是“help”?回复句号以使用推测的指令。') await client.shouldReply('.', message) await client.shouldReply('help -h', message) await client.shouldReply('help 帮助', message)