bibot 1.0.22 → 1.0.23

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.
@@ -3517,64 +3517,49 @@ var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(p
3517
3517
  return Promise.reject(e);
3518
3518
  }
3519
3519
  };
3520
+ var handleRetries = function handleRetries(data, attempt) {
3521
+ try {
3522
+ var maxAttempts = 30;
3523
+ var delay = 10000;
3524
+ if (attempt >= maxAttempts) {
3525
+ return Promise.resolve("Sorry this is taking longer than usual. Please try again later");
3526
+ }
3527
+ return Promise.resolve(new Promise(function (resolve) {
3528
+ return setTimeout(resolve, delay);
3529
+ })).then(function () {
3530
+ return _catch(function () {
3531
+ return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
3532
+ tries: attempt + 1
3533
+ }))).then(function (message) {
3534
+ if (message === defaultSlacker) {
3535
+ return Promise.resolve(handleRetries(data, attempt + 1));
3536
+ } else {
3537
+ return message;
3538
+ }
3539
+ });
3540
+ }, function (error) {
3541
+ return error.message;
3542
+ });
3543
+ });
3544
+ } catch (e) {
3545
+ return Promise.reject(e);
3546
+ }
3547
+ };
3520
3548
  var askBiBot = function askBiBot(data) {
3521
3549
  try {
3522
3550
  return Promise.resolve(_catch(function () {
3523
3551
  var path = "" + domain.inference + resources.q;
3524
3552
  return Promise.resolve(pluginAxiosInstance.post(path, data)).then(function (response) {
3525
3553
  if (response.data.message === defaultSlacker) {
3526
- return _catch(function () {
3527
- return Promise.resolve(new Promise(function (resolve) {
3528
- return setTimeout(resolve, 6000);
3529
- })).then(function () {
3530
- return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
3531
- tries: 2
3532
- })));
3533
- });
3534
- }, function (error2) {
3535
- if (error2.code === 'ECONNABORTED' || error2.message.includes('Endpoint request timed out')) {
3536
- return _catch(function () {
3537
- return Promise.resolve(new Promise(function (resolve) {
3538
- return setTimeout(resolve, 6000);
3539
- })).then(function () {
3540
- return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
3541
- tries: 3
3542
- })));
3543
- });
3544
- }, function (error3) {
3545
- return error3.message;
3546
- });
3547
- } else {
3548
- return error2.message;
3549
- }
3550
- });
3554
+ return Promise.resolve(handleRetries(data, 1));
3551
3555
  } else {
3552
3556
  return response.data.message;
3553
3557
  }
3554
3558
  });
3555
3559
  }, function (error1) {
3560
+ console.log('This is the error1 from the endpoint on the 1st try:', error1);
3556
3561
  console.log(error1.message);
3557
- if (error1.code === 'ECONNABORTED' || error1.message.includes('Endpoint request timed out')) {
3558
- return _catch(function () {
3559
- return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
3560
- tries: 2
3561
- })));
3562
- }, function (error2) {
3563
- if (error2.code === 'ECONNABORTED' || error2.message.includes('Endpoint request timed out')) {
3564
- return _catch(function () {
3565
- return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
3566
- tries: 3
3567
- })));
3568
- }, function (error3) {
3569
- return error3.message;
3570
- });
3571
- } else {
3572
- return error2.message;
3573
- }
3574
- });
3575
- } else {
3576
- return error1.message;
3577
- }
3562
+ return error1.message;
3578
3563
  }));
3579
3564
  } catch (e) {
3580
3565
  return Promise.reject(e);
@@ -3596,7 +3581,7 @@ var askTimedOutBiBot = function askTimedOutBiBot(data) {
3596
3581
  return Promise.reject(e);
3597
3582
  }
3598
3583
  };
3599
- var defaultSlacker = "Unfortunately I could not find any information that reasonably answers that question. I just forwarded your inquiry to support, they will respond ASAP.";
3584
+ var defaultSlacker = "BiBot_Retry_Later";
3600
3585
  var pluginAxiosInstance = createPluginAxiosInstance();
3601
3586
 
3602
3587
  var useBiBotChatBot = function useBiBotChatBot(_ref) {