wingbot 3.40.1 → 3.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Plugins.js +3 -2
- package/src/Responder.js +3 -2
- package/src/Tester.js +2 -0
- package/src/utils/compileWithState.js +1 -0
- package/src/utils/slots.js +8 -2
package/package.json
CHANGED
package/src/Plugins.js
CHANGED
|
@@ -42,7 +42,7 @@ const wrapPluginFunction = require('./utils/wrapPluginFunction');
|
|
|
42
42
|
* Custom code plugins for BuildRouter and wingbot.ai
|
|
43
43
|
*
|
|
44
44
|
* @template {object} [S=object]
|
|
45
|
-
* @template {object} C=Object
|
|
45
|
+
* @template {object} [C=Object]
|
|
46
46
|
* @class Plugins
|
|
47
47
|
*/
|
|
48
48
|
class Plugins {
|
|
@@ -72,7 +72,7 @@ class Plugins {
|
|
|
72
72
|
*
|
|
73
73
|
* @param {string} name
|
|
74
74
|
* @param {object} [paramsData]
|
|
75
|
-
* @param {Map<string,Function[]>|Object<string,
|
|
75
|
+
* @param {Map<string,Function[]>|Object<string,Middleware<S>>} [items]
|
|
76
76
|
* @param {object} [context]
|
|
77
77
|
* @param {boolean} [context.isLastIndex]
|
|
78
78
|
* @param {Router} [context.router]
|
|
@@ -104,6 +104,7 @@ class Plugins {
|
|
|
104
104
|
let useItems = items;
|
|
105
105
|
|
|
106
106
|
if (!(items instanceof Map)) {
|
|
107
|
+
// @ts-ignore
|
|
107
108
|
useItems = new Map(
|
|
108
109
|
Object.keys(items)
|
|
109
110
|
.map((key) => [
|
package/src/Responder.js
CHANGED
|
@@ -25,7 +25,8 @@ const EXCEPTION_HOPCOUNT_THRESHOLD = 5;
|
|
|
25
25
|
/** @typedef {import('./Request')} Request */
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* @enum {string}
|
|
28
|
+
* @enum {string} ExpectedInput
|
|
29
|
+
* @readonly
|
|
29
30
|
*/
|
|
30
31
|
const ExpectedInput = {
|
|
31
32
|
TYPE_PASSWORD: 'password'
|
|
@@ -95,7 +96,7 @@ class Responder {
|
|
|
95
96
|
};
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
|
-
* @
|
|
99
|
+
* @prop {Object<keyof ExpectedInput,ExpectedInput>}
|
|
99
100
|
*/
|
|
100
101
|
this.ExpectedInputTypes = ExpectedInput;
|
|
101
102
|
|
package/src/Tester.js
CHANGED
|
@@ -230,6 +230,8 @@ class Tester {
|
|
|
230
230
|
&& !(res.status === 204 && this._pluginBlocksCollector.length > 0)
|
|
231
231
|
&& !(res.status === 204 && this.allowEmptyResponse)) {
|
|
232
232
|
|
|
233
|
+
this.debug();
|
|
234
|
+
|
|
233
235
|
if (res.status === 204) {
|
|
234
236
|
throw Object.assign(new Error(`Bot did not respond (status ${res.status})`), { code: res.status });
|
|
235
237
|
}
|
package/src/utils/slots.js
CHANGED
|
@@ -69,13 +69,19 @@ const StepState = {
|
|
|
69
69
|
async function getNextStep (req, res, postBack) {
|
|
70
70
|
let invalid = null;
|
|
71
71
|
const {
|
|
72
|
-
_slotState: slotState, _slotSteps: steps, _slotDone: doneAction
|
|
72
|
+
_slotState: slotState, _slotSteps: steps, _slotDone: doneAction, ...rest
|
|
73
73
|
} = { ...req.state, ...res.newState };
|
|
74
74
|
|
|
75
75
|
for (const slot of slotState) {
|
|
76
76
|
const step = steps.find((s) => s.entity === slot.e);
|
|
77
|
+
if (step && slot.s === StepState.INITIALIZED && (
|
|
78
|
+
(step.type !== StepType.MULTI && rest[slot.e])
|
|
79
|
+
|| (step.type === StepType.MULTI && rest[slot.e.replace(/^@/, '+')] && rest[slot.e.replace(/^@/, '+')].length))) {
|
|
80
|
+
|
|
81
|
+
slot.s = StepState.FILLED;
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
if (slot.s === StepState.FILLED && step && step.validateAction) {
|
|
78
|
-
// eslint-disable-next-line
|
|
79
85
|
await postBack(step.validateAction, {}, true);
|
|
80
86
|
if (res.finalMessageSent) {
|
|
81
87
|
invalid = step;
|