wingbot 3.27.0-alpha.4 → 3.27.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.27.0-alpha.4",
3
+ "version": "3.27.2",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/BotApp.js CHANGED
@@ -262,7 +262,8 @@ class BotApp {
262
262
  pageId,
263
263
  appId,
264
264
  secret,
265
- fetch: this._fetch
265
+ fetch: this._fetch,
266
+ tls: this._tls
266
267
  };
267
268
 
268
269
  const sender = new BotAppSender(options, senderId, message, this._senderLogger);
@@ -58,6 +58,14 @@ const { replaceDiacritics } = require('../utils');
58
58
 
59
59
  /** @typedef {import('../Request')} Request */
60
60
 
61
+ function optionalWrap (l, r, content) {
62
+ const consistent = !l === !r;
63
+ if (consistent) {
64
+ return `(${content})`;
65
+ }
66
+ return `${l || ''}(${content})${r || ''}`;
67
+ }
68
+
61
69
  class CustomEntityDetectionModel {
62
70
 
63
71
  /**
@@ -165,8 +173,9 @@ class CustomEntityDetectionModel {
165
173
  ]);
166
174
 
167
175
  const cleanSubWordResults = subWordResults
168
- .filter((regular) => regularResults
169
- .some((e) => e.start < regular.end && e.end > regular.start));
176
+ .filter((regular) => !regularResults
177
+ .some((e) => e.start < regular.end && e.end > regular.start
178
+ && e.end >= regular.end && e.start <= regular.start));
170
179
 
171
180
  subWord.push(...cleanSubWordResults);
172
181
 
@@ -507,16 +516,16 @@ class CustomEntityDetectionModel {
507
516
  return null;
508
517
  }
509
518
 
510
- let replaced = source.replace(/@[A-Z0-9-]+/g, (value) => {
519
+ let replaced = source.replace(/(\()?@([A-Z0-9-]+)(\))?/g, (value, l, ent, r) => {
511
520
  const matchingEntities = entities
512
- .filter((e) => `@${e.entity.toUpperCase()}` === value)
521
+ .filter((e) => e.entity.toUpperCase() === ent)
513
522
  .map((e) => this._escapeRegex(e.text, options.replaceDiacritics));
514
523
 
515
524
  if (matchingEntities.length === 0) {
516
- return value;
525
+ return optionalWrap(l, r, `@${ent}`);
517
526
  }
518
527
  matchingEntities.sort((a, z) => z.length - a.length);
519
- return `(${matchingEntities.join('|')})`;
528
+ return optionalWrap(l, r, matchingEntities.join('|'));
520
529
  });
521
530
 
522
531
  if (options.matchWholeWords && !searchWithinWords) {