Skip to content

Commit

Permalink
core: replies should not be interpreted as command calls, fix #95
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Aug 28, 2020
1 parent b536a86 commit 92f9b79
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/koishi-core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ export class App extends Context {
await session.$group?._update()
}

private _parse(message: string, { $prefix, $appel, messageType }: Session, builtin: boolean, terminator = '') {
private _parse(message: string, { $reply, $prefix, $appel, messageType }: Session, builtin: boolean, terminator = '') {
// group message should have prefix or appel to be interpreted as a command call
if (builtin && messageType !== 'private' && $prefix === null && !$appel) return
if (builtin && ($reply || messageType !== 'private' && $prefix === null && !$appel)) return
terminator = escapeRegExp(terminator)
const name = message.split(new RegExp(`[\\s${terminator}]`), 1)[0]
const index = name.lastIndexOf('/')
Expand Down
4 changes: 2 additions & 2 deletions packages/koishi-core/src/plugins/shortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default function apply(ctx: Context) {
}
})

ctx.on('parse', (message, { $prefix, $appel }, builtin) => {
if (!builtin || $prefix) return
ctx.on('parse', (message, { $reply, $prefix, $appel }, builtin) => {
if (!builtin || $prefix || $reply) return
for (const shortcut of ctx.app._shortcuts) {
const { name, fuzzy, command, oneArg, prefix, options, args = [] } = shortcut
if (prefix && !$appel) continue
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-teach/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function registerPrefix(ctx: Context, prefix: string) {
// $1 $2

ctx.on('parse', (source, session, builtin) => {
if (builtin && session.$prefix) return
if (builtin && session.$prefix || session.$reply) return
const capture = source.match(teachRegExp)
if (!capture) return

Expand Down

0 comments on commit 92f9b79

Please sign in to comment.