koishi-plugin-teach
Advanced tools
Comparing version 1.0.3 to 1.0.4
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -13,3 +10,3 @@ const koishi_core_1 = require("koishi-core"); | ||
const util_1 = require("util"); | ||
const leven_1 = __importDefault(require("leven")); | ||
const fastest_levenshtein_1 = require("fastest-levenshtein"); | ||
koishi_core_1.Message.Teach = {}; | ||
@@ -58,5 +55,5 @@ koishi_core_1.Message.Teach.TooManyArguments = '存在多余的参数,请检查指令语法或将含有空格或换行的问答置于一对引号内。'; | ||
return dialogues.every(dialogue => { | ||
const dist = leven_1.default(question, dialogue.answer); | ||
const dist = fastest_levenshtein_1.distance(question, dialogue.answer); | ||
return dist < dialogue.answer.length / 2 | ||
&& dist < leven_1.default(question, dialogue.question); | ||
&& dist < fastest_levenshtein_1.distance(question, dialogue.question); | ||
}); | ||
@@ -63,0 +60,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const koishi_utils_1 = require("koishi-utils"); | ||
function apply(ctx, config) { | ||
@@ -7,3 +8,3 @@ const { preventLoop } = config; | ||
: typeof preventLoop === 'number' ? [{ length: preventLoop, participants: 1 }] | ||
: Array.isArray(preventLoop) ? preventLoop : [preventLoop]; | ||
: koishi_utils_1.makeArray(preventLoop); | ||
const initiatorCount = Math.max(0, ...preventLoopConfig.map(c => c.length)); | ||
@@ -10,0 +11,0 @@ ctx.on('dialogue/state', (state) => { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const koishi_utils_1 = require("koishi-utils"); | ||
function apply(ctx, config) { | ||
const { throttle } = config; | ||
const throttleConfig = !throttle ? [] | ||
: Array.isArray(throttle) ? throttle | ||
: [throttle]; | ||
const throttleConfig = koishi_utils_1.makeArray(config.throttle); | ||
const counters = {}; | ||
@@ -9,0 +7,0 @@ for (const { interval, responses } of throttleConfig) { |
@@ -184,4 +184,4 @@ "use strict"; | ||
const { nickname = ctx.app.options.nickname, maxRedirections = 3 } = config; | ||
const nicknames = Array.isArray(nickname) ? nickname : nickname ? [nickname] : []; | ||
const nicknameRE = new RegExp(`^((${nicknames.map(koishi_utils_1.escapeRegExp).join('|')})[,,]?\\s*)+`); | ||
const nicknames = koishi_utils_1.makeArray(nickname).map(koishi_utils_1.escapeRegExp); | ||
const nicknameRE = new RegExp(`^((${nicknames.join('|')})[,,]?\\s*)+`); | ||
ctx.app._dialogueStates = {}; | ||
@@ -188,0 +188,0 @@ config._stripQuestion = (source) => { |
{ | ||
"name": "koishi-plugin-teach", | ||
"description": "Teach plugin for Koishi", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"main": "dist/index.js", | ||
@@ -41,15 +41,15 @@ "typings": "dist/index.d.ts", | ||
"peerDependencies": { | ||
"koishi-core": "^2.1.1" | ||
"koishi-core": "^2.2.2" | ||
}, | ||
"devDependencies": { | ||
"koishi-plugin-mongo": "^1.0.2", | ||
"koishi-plugin-mongo": "^1.0.3", | ||
"koishi-plugin-mysql": "^2.0.0", | ||
"koishi-test-utils": "^4.0.0" | ||
"koishi-test-utils": "^5.0.1" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.20.0", | ||
"koishi-utils": "^3.1.3", | ||
"leven": "^3.1.0", | ||
"fastest-levenshtein": "^1.0.12", | ||
"koishi-utils": "^3.1.5", | ||
"regexpp": "^3.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
222107
2909
+ Addedfastest-levenshtein@^1.0.12
- Removedleven@^3.1.0
- Removedleven@3.1.0(transitive)
Updatedkoishi-utils@^3.1.5