wingbot 3.67.16 → 3.67.18
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/Ai.js +1 -0
- package/src/ReturnSender.js +45 -0
package/package.json
CHANGED
package/src/Ai.js
CHANGED
package/src/ReturnSender.js
CHANGED
|
@@ -465,6 +465,28 @@ class ReturnSender {
|
|
|
465
465
|
throw new Error('#upload() not supported by this channel');
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
+
_isVisibleMessage (event, needTitle = true) {
|
|
469
|
+
// @todo is also in orchestrator
|
|
470
|
+
|
|
471
|
+
if (event.message) {
|
|
472
|
+
return !!(event.message.text
|
|
473
|
+
|| event.message.attachment
|
|
474
|
+
|| event.message.attachments);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (event.sender_action) {
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (event.postback
|
|
482
|
+
&& (!needTitle || event.postback.title)) {
|
|
483
|
+
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
|
|
468
490
|
send (payload) {
|
|
469
491
|
if (this._finished) {
|
|
470
492
|
throw new Error('Cannot send message after sender is finished');
|
|
@@ -483,6 +505,29 @@ class ReturnSender {
|
|
|
483
505
|
return;
|
|
484
506
|
}
|
|
485
507
|
|
|
508
|
+
const lastInQueue = this._queue[this._queue.length - 1];
|
|
509
|
+
|
|
510
|
+
if (payload.set_context
|
|
511
|
+
&& !this._isVisibleMessage(payload, false)
|
|
512
|
+
&& lastInQueue
|
|
513
|
+
&& this._isVisibleMessage(lastInQueue)) {
|
|
514
|
+
|
|
515
|
+
const { set_context: setContext, ...rest } = payload;
|
|
516
|
+
|
|
517
|
+
Object.assign(
|
|
518
|
+
lastInQueue,
|
|
519
|
+
rest,
|
|
520
|
+
lastInQueue,
|
|
521
|
+
{
|
|
522
|
+
set_context: {
|
|
523
|
+
...lastInQueue.set_context,
|
|
524
|
+
...setContext
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
|
|
486
531
|
const text = extractText(payload);
|
|
487
532
|
if (text) {
|
|
488
533
|
this._responseTexts.push(text);
|