Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-moe committed Aug 27, 2020
1 parent 33f1987 commit 5a4a811
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/plugin-teach/src/database/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Context, extendDatabase } from 'koishi-core'
import { clone, defineProperty, Observed, pick } from 'koishi-utils'
import { FilterQuery } from 'mongodb'
import MongoDatabase from 'koishi-plugin-mongo/dist/database'
import { Dialogue, DialogueTest } from '../utils'
import { Dialogue, DialogueTest, equal } from '../utils'

declare module 'koishi-core/dist/context' {
interface EventMap {
Expand Down Expand Up @@ -31,7 +31,10 @@ extendDatabase<typeof MongoDatabase>('koishi-plugin-mongo', {
return dialogues.filter(value => {
if (value.flag & Dialogue.Flag.regexp) {
const regex = new RegExp(value.question, 'i')
return regex.test(test.question) || regex.test(test.original)
if (!(regex.test(test.question) || regex.test(test.original))) return false
}
if (test.groups && !test.partial) {
return !(value.flag & Dialogue.Flag.complement) === test.reversed || !equal(test.groups, value.groups)
}
return true
})
Expand Down

0 comments on commit 5a4a811

Please sign in to comment.