Skip to content

Commit

Permalink
fix(teach): braces should not be stripped for regexp questions
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 13, 2020
1 parent 99fff9e commit 9b7f3eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/plugin-teach/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ export default function apply(ctx: Context, config: Dialogue.Config) {
return Message.Teach.ProhibitedCQCode
}

const { unprefixed, prefixed, appellative } = config._stripQuestion(options.question)
const { unprefixed, prefixed, appellative } = options.regexp
? { unprefixed: question, prefixed: question, appellative: false }
: config._stripQuestion(question)
argv.appellative = appellative
Object.defineProperty(options, '_original', { value: prefixed })
if (unprefixed) {
options.original = options.question
options.original = question
options.question = unprefixed
} else {
delete options.question
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-teach/src/receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export default function (ctx: Context, config: Dialogue.Config) {
}

function prepareSource(source: string) {
return CQCode.stringifyAll(CQCode.parseAll(source || '').map((code, index, arr) => {
return CQCode.stringifyAll(CQCode.parseAll(source).map((code, index, arr) => {
if (typeof code !== 'string') return code
let message = simplify(CQCode.unescape('' + code))
.toLowerCase()
Expand Down

0 comments on commit 9b7f3eb

Please sign in to comment.