Refactoring
This commit is contained in:
1 parent
0ca419ab0d
commit
b56e0f0125
2 files changed
+17
-17
No files matched your search
+11
-11
@@ -13,17 +13,17 @@
|
||||
logger.initialize();
|
||||
|
||||
let thisObject = {
|
||||
requireBot: requireBot,
|
||||
requireCommons: requireCommons
|
||||
downloadBot: downloadBot,
|
||||
downloadCommons: downloadCommons
|
||||
};
|
||||
|
||||
return thisObject;
|
||||
|
||||
function requireBot(pCloudStorage, pProcessConfig, callBackFunction) {
|
||||
function downloadBot(pCloudStorage, pProcessConfig, callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] requireBot -> Entering function."); }
|
||||
if (FULL_LOG === true) { logger.write("[INFO] downloadBot -> Entering function."); }
|
||||
|
||||
let filePath = bot.devTeam + "/" + bot.repo + "/" + pProcessConfig.name;
|
||||
let fileName = "User.Bot.js";
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
logger.write("[ERROR] requireBot -> onFileReceived -> err.message = " + err.message);
|
||||
logger.write("[ERROR] downloadBot -> onFileReceived -> err.message = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
@@ -47,23 +47,23 @@
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE, USER_BOT_MODULE);
|
||||
|
||||
} catch (err) {
|
||||
logger.write("[ERROR] requireBot -> onFileReceived -> err.message = " + err.message);
|
||||
logger.write("[ERROR] downloadBot -> onFileReceived -> err.message = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
logger.write("[ERROR] requireBot -> err = " + err.message);
|
||||
logger.write("[ERROR] downloadBot -> err = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function requireCommons(pCloudStorage, callBackFunction) {
|
||||
function downloadCommons(pCloudStorage, callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] requireCommons -> Entering function."); }
|
||||
if (FULL_LOG === true) { logger.write("[INFO] downloadCommons -> Entering function."); }
|
||||
|
||||
let filePath = bot.devTeam + "/" + bot.repo;
|
||||
let fileName = "Commons.js";
|
||||
@@ -87,14 +87,14 @@
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE, COMMONS_MODULE);
|
||||
|
||||
} catch (err) {
|
||||
logger.write("[ERROR] requireCommons -> onFileReceived -> err.message = " + err.message);
|
||||
logger.write("[ERROR] downloadCommons -> onFileReceived -> err.message = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
logger.write("[ERROR] requireCommons -> err = " + err.message);
|
||||
logger.write("[ERROR] downloadCommons -> err = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@
|
||||
const CLOUD_REQUIRE = require(ROOT_DIR + 'CloudRequire');
|
||||
let cloudRequire = CLOUD_REQUIRE.newCloudRequire(bot, DEBUG_MODULE);
|
||||
|
||||
cloudRequire.requireBot(cloudStorage, pProcessConfig, onBotRequired);
|
||||
cloudRequire.downloadBot(cloudStorage, pProcessConfig, onBotDownloaded);
|
||||
|
||||
function onBotRequired(err, pMODULE) {
|
||||
function onBotDownloaded(err, pMODULE) {
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
logger.write("[ERROR] initialize -> onInizialized -> onBotRequired -> err.message = " + err.message);
|
||||
logger.write("[ERROR] initialize -> onInizialized -> onBotDownloaded -> err.message = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
bot.eventHandler.raiseEvent("Loop Finished");
|
||||
return;
|
||||
@@ -66,13 +66,13 @@
|
||||
|
||||
USER_BOT_MODULE = pMODULE;
|
||||
|
||||
cloudRequire.requireCommons(cloudStorage, onCommonsRequired);
|
||||
cloudRequire.downloadCommons(cloudStorage, onCommonsDownloaded);
|
||||
|
||||
function onCommonsRequired(err, pMODULE) {
|
||||
function onCommonsDownloaded(err, pMODULE) {
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
logger.write("[ERROR] initialize -> onInizialized -> onBotRequired -> onCommonsRequired -> err.message = " + err.message);
|
||||
logger.write("[ERROR] initialize -> onInizialized -> onBotDownloaded -> onCommonsDownloaded -> err.message = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
bot.eventHandler.raiseEvent("Loop Finished");
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user