wingbot 3.69.5 → 3.69.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.69.5",
3
+ "version": "3.69.7",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -69,4 +69,4 @@
69
69
  "axios": "^1.6.4",
70
70
  "handlebars": "^4.0.0"
71
71
  }
72
- }
72
+ }
package/src/Plugins.js CHANGED
@@ -9,6 +9,7 @@ const Router = require('./Router'); // eslint-disable-line no-unused-vars
9
9
  const plugins = require('../plugins');
10
10
  const RouterWrap = require('./RouterWrap');
11
11
  const wrapPluginFunction = require('./utils/wrapPluginFunction');
12
+ const { compileWithState } = require('./utils');
12
13
 
13
14
  /** @typedef {import('./Router').BaseConfiguration} BaseConfiguration */
14
15
 
@@ -101,7 +102,7 @@ class Plugins {
101
102
  *
102
103
  * @param {string} name
103
104
  * @param {object} [paramsData]
104
- * @param {Map<string,Function[]>|Object<string,Middleware<S>>} [items]
105
+ * @param {Map<string,Function[]>|Object<string,Middleware<S>|string>} [items]
105
106
  * @param {object} [context]
106
107
  * @param {boolean} [context.isLastIndex]
107
108
  * @param {Router} [context.router]
@@ -138,10 +139,20 @@ class Plugins {
138
139
  // @ts-ignore
139
140
  useItems = new Map(
140
141
  Object.keys(items)
141
- .map((key) => [
142
- key,
143
- [items[key]]
144
- ])
142
+ .map((key) => {
143
+ const responder = typeof items[key] === 'function'
144
+ ? items[key]
145
+ : (req, res) => {
146
+ // @ts-ignore
147
+ const text = compileWithState(req, res, items[key]);
148
+ res.text(text);
149
+ };
150
+
151
+ return [
152
+ key,
153
+ [responder]
154
+ ];
155
+ })
145
156
  );
146
157
  }
147
158
 
@@ -219,7 +219,7 @@ function makeQuickReplies (replies, path = '', translate = (w) => w, quickReplyC
219
219
 
220
220
  const hasData = Object.keys(data).length !== 0;
221
221
  const hasSetState = setState && Object.keys(setState).length !== 0;
222
- const translatedTitle = translate(title);
222
+ const translatedTitle = translate(title, { quickReply: true });
223
223
 
224
224
  if (hasSetState) {
225
225
  // replace {{this}}