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.
- package/dist/index.js +32 -47
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +32 -47
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -3520,64 +3520,49 @@ var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(p
|
|
3520
3520
|
return Promise.reject(e);
|
3521
3521
|
}
|
3522
3522
|
};
|
3523
|
+
var handleRetries = function handleRetries(data, attempt) {
|
3524
|
+
try {
|
3525
|
+
var maxAttempts = 30;
|
3526
|
+
var delay = 10000;
|
3527
|
+
if (attempt >= maxAttempts) {
|
3528
|
+
return Promise.resolve("Sorry this is taking longer than usual. Please try again later");
|
3529
|
+
}
|
3530
|
+
return Promise.resolve(new Promise(function (resolve) {
|
3531
|
+
return setTimeout(resolve, delay);
|
3532
|
+
})).then(function () {
|
3533
|
+
return _catch(function () {
|
3534
|
+
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3535
|
+
tries: attempt + 1
|
3536
|
+
}))).then(function (message) {
|
3537
|
+
if (message === defaultSlacker) {
|
3538
|
+
return Promise.resolve(handleRetries(data, attempt + 1));
|
3539
|
+
} else {
|
3540
|
+
return message;
|
3541
|
+
}
|
3542
|
+
});
|
3543
|
+
}, function (error) {
|
3544
|
+
return error.message;
|
3545
|
+
});
|
3546
|
+
});
|
3547
|
+
} catch (e) {
|
3548
|
+
return Promise.reject(e);
|
3549
|
+
}
|
3550
|
+
};
|
3523
3551
|
var askBiBot = function askBiBot(data) {
|
3524
3552
|
try {
|
3525
3553
|
return Promise.resolve(_catch(function () {
|
3526
3554
|
var path = "" + domain.inference + resources.q;
|
3527
3555
|
return Promise.resolve(pluginAxiosInstance.post(path, data)).then(function (response) {
|
3528
3556
|
if (response.data.message === defaultSlacker) {
|
3529
|
-
return
|
3530
|
-
return Promise.resolve(new Promise(function (resolve) {
|
3531
|
-
return setTimeout(resolve, 6000);
|
3532
|
-
})).then(function () {
|
3533
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3534
|
-
tries: 2
|
3535
|
-
})));
|
3536
|
-
});
|
3537
|
-
}, function (error2) {
|
3538
|
-
if (error2.code === 'ECONNABORTED' || error2.message.includes('Endpoint request timed out')) {
|
3539
|
-
return _catch(function () {
|
3540
|
-
return Promise.resolve(new Promise(function (resolve) {
|
3541
|
-
return setTimeout(resolve, 6000);
|
3542
|
-
})).then(function () {
|
3543
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3544
|
-
tries: 3
|
3545
|
-
})));
|
3546
|
-
});
|
3547
|
-
}, function (error3) {
|
3548
|
-
return error3.message;
|
3549
|
-
});
|
3550
|
-
} else {
|
3551
|
-
return error2.message;
|
3552
|
-
}
|
3553
|
-
});
|
3557
|
+
return Promise.resolve(handleRetries(data, 1));
|
3554
3558
|
} else {
|
3555
3559
|
return response.data.message;
|
3556
3560
|
}
|
3557
3561
|
});
|
3558
3562
|
}, function (error1) {
|
3563
|
+
console.log('This is the error1 from the endpoint on the 1st try:', error1);
|
3559
3564
|
console.log(error1.message);
|
3560
|
-
|
3561
|
-
return _catch(function () {
|
3562
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3563
|
-
tries: 2
|
3564
|
-
})));
|
3565
|
-
}, function (error2) {
|
3566
|
-
if (error2.code === 'ECONNABORTED' || error2.message.includes('Endpoint request timed out')) {
|
3567
|
-
return _catch(function () {
|
3568
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3569
|
-
tries: 3
|
3570
|
-
})));
|
3571
|
-
}, function (error3) {
|
3572
|
-
return error3.message;
|
3573
|
-
});
|
3574
|
-
} else {
|
3575
|
-
return error2.message;
|
3576
|
-
}
|
3577
|
-
});
|
3578
|
-
} else {
|
3579
|
-
return error1.message;
|
3580
|
-
}
|
3565
|
+
return error1.message;
|
3581
3566
|
}));
|
3582
3567
|
} catch (e) {
|
3583
3568
|
return Promise.reject(e);
|
@@ -3599,7 +3584,7 @@ var askTimedOutBiBot = function askTimedOutBiBot(data) {
|
|
3599
3584
|
return Promise.reject(e);
|
3600
3585
|
}
|
3601
3586
|
};
|
3602
|
-
var defaultSlacker = "
|
3587
|
+
var defaultSlacker = "BiBot_Retry_Later";
|
3603
3588
|
var pluginAxiosInstance = createPluginAxiosInstance();
|
3604
3589
|
|
3605
3590
|
var useBiBotChatBot = function useBiBotChatBot(_ref) {
|