koishi-plugin-teach
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -68,2 +68,5 @@ "use strict"; | ||
const { question, answer, ignoreHint, regexp } = options; | ||
function applySuggestion(argv) { | ||
return argv.target ? update_1.update(argv) : update_1.create(argv); | ||
} | ||
// 修改问答时发现可能想改回答但是改了问题 | ||
@@ -78,3 +81,3 @@ if (target && !ignoreHint && question && !answer && maybeAnswer(question, dialogues)) { | ||
delete options.question; | ||
return update_1.update(argv); | ||
return applySuggestion(argv); | ||
}); | ||
@@ -91,3 +94,3 @@ return koishi_core_1.Message.Teach.MayModifyAnswer; | ||
options.regexp = true; | ||
return update_1.update(argv); | ||
return applySuggestion(argv); | ||
}); | ||
@@ -94,0 +97,0 @@ return util_1.format(koishi_core_1.Message.Teach.MaybeRegExp, target ? '修改' : '添加'); |
@@ -76,3 +76,3 @@ import { Context, User, Session, NextFunction } from 'koishi-core'; | ||
export declare function triggerDialogue(ctx: Context, session: Session, next?: NextFunction): Promise<void>; | ||
export default function (ctx: Context, config: Dialogue.Config): void; | ||
export default function apply(ctx: Context, config: Dialogue.Config): void; | ||
export {}; |
@@ -166,3 +166,4 @@ "use strict"; | ||
else if (char === '{') { | ||
const argv = session.$parse(state.answer, '}'); | ||
const message = unescapeAnswer(state.answer); | ||
const argv = session.$parse(message, '}'); | ||
if (argv) { | ||
@@ -173,3 +174,3 @@ state.answer = argv.rest.slice(1); | ||
else { | ||
logger.warn('cannot parse:', state.answer); | ||
logger.warn('cannot parse:', message); | ||
const index = state.answer.indexOf('}'); | ||
@@ -184,3 +185,3 @@ state.answer = state.answer.slice(index + 1); | ||
exports.triggerDialogue = triggerDialogue; | ||
function default_1(ctx, config) { | ||
function apply(ctx, config) { | ||
const { nickname = ctx.app.options.nickname, maxRedirections = 3 } = config; | ||
@@ -203,2 +204,9 @@ const nicknames = koishi_utils_1.makeArray(nickname).map(koishi_utils_1.escapeRegExp); | ||
}; | ||
ctx.prependListener('parse', (message, session) => { | ||
if (session.$appel) | ||
return; | ||
const { activated } = ctx.getSessionState(session); | ||
if (activated[session.userId]) | ||
session.$appel = true; | ||
}); | ||
ctx.group().middleware(async (session, next) => { | ||
@@ -250,3 +258,3 @@ return triggerDialogue(ctx, session, next); | ||
} | ||
exports.default = default_1; | ||
exports.default = apply; | ||
function prepareSource(source) { | ||
@@ -253,0 +261,0 @@ return koishi_utils_1.CQCode.stringifyAll(koishi_utils_1.CQCode.parseAll(source).map((code, index, arr) => { |
{ | ||
"name": "koishi-plugin-teach", | ||
"description": "Teach plugin for Koishi", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"main": "dist/index.js", | ||
@@ -41,12 +41,12 @@ "typings": "dist/index.d.ts", | ||
"peerDependencies": { | ||
"koishi-core": "^2.4.0", | ||
"koishi-core": "^2.4.2", | ||
"koishi-utils": "^3.1.5" | ||
}, | ||
"devDependencies": { | ||
"koishi-plugin-mongo": "^1.1.1", | ||
"koishi-plugin-mysql": "^2.0.2", | ||
"koishi-test-utils": "^5.0.2" | ||
"koishi-plugin-mongo": "^1.1.2", | ||
"koishi-plugin-mysql": "^2.1.0", | ||
"koishi-test-utils": "^5.0.3" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.20.0", | ||
"axios": "^0.21.0", | ||
"fastest-levenshtein": "^1.0.12", | ||
@@ -53,0 +53,0 @@ "regexpp": "^3.1.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
227394
2976
+ Addedaxios@0.21.4(transitive)
- Removedaxios@0.20.0(transitive)
Updatedaxios@^0.21.0