Skip to content

Commit

Permalink
fix(core): check context for shortcut, fix #159
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Mar 18, 2021
1 parent a976035 commit 49c2c39
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/koishi-core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 49c2c39

Please sign in to comment.