From 49c2c398c956cd6365e3462a5c38168a8011ba97 Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Thu, 18 Mar 2021 22:40:11 +0800 Subject: [PATCH] fix(core): check context for shortcut, fix #159 --- packages/koishi-core/src/app.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/koishi-core/src/app.ts b/packages/koishi-core/src/app.ts index 3190da8d8f..8b1cfd7349 100644 --- a/packages/koishi-core/src/app.ts +++ b/packages/koishi-core/src/app.ts @@ -346,11 +346,12 @@ export class App extends Context { return argv } - private _handleShortcut(content: string, { parsed, quote }: Session) { + private _handleShortcut(content: string, session: Session) { + const { parsed, quote } = session if (parsed.prefix || quote) return for (const shortcut of this._shortcuts) { const { name, fuzzy, command, greedy, prefix, options = {}, args = [] } = shortcut - if (prefix && !parsed.appel) continue + if (prefix && !parsed.appel || !command.context.match(session)) continue if (typeof name === 'string') { if (!fuzzy && content !== name || !content.startsWith(name)) continue const message = content.slice(name.length)