Enhance init logging + add more user setting file generation error handling
This commit is contained in:
parent
a87de44e61
commit
16af27106f
24
bot.js
24
bot.js
@ -1,3 +1,10 @@
|
|||||||
|
// Mercury RSS Client - git.supernets.org/hgw/mercury
|
||||||
|
// ____ ___ ___ ____________ _________ __
|
||||||
|
// / __ `__ \/ _ \/ ___/ ___/ / / / ___/ / / /
|
||||||
|
// / / / / / / __/ / / /__/ /_/ / / / /_/ /
|
||||||
|
// /_/ /_/ /_/\___/_/ \___/\__,_/_/ \__, /
|
||||||
|
// COLD HARD FEEDS /____/
|
||||||
|
//
|
||||||
var config = require('./config/default.json');
|
var config = require('./config/default.json');
|
||||||
//var uconfig = require('./config/usersettings.json');
|
//var uconfig = require('./config/usersettings.json');
|
||||||
var irc = require("irc");
|
var irc = require("irc");
|
||||||
@ -202,7 +209,6 @@ bot.addListener('error', function(message) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
consoleLog('[bot.init] Welcome to Mercury');
|
|
||||||
consoleLog('[bot.init] Checking config validity')
|
consoleLog('[bot.init] Checking config validity')
|
||||||
checkConfigValidity()
|
checkConfigValidity()
|
||||||
await timer(1500)
|
await timer(1500)
|
||||||
@ -212,16 +218,30 @@ async function init() {
|
|||||||
fs.writeFile('./config/usersettings.json', '', function(err) {
|
fs.writeFile('./config/usersettings.json', '', function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
consoleLog(err);
|
consoleLog(err);
|
||||||
|
consoleLog('[bot.init] [FATAL] User settings file could not be created. Mercury can not start')
|
||||||
|
process.exit()
|
||||||
}
|
}
|
||||||
consoleLog("[bot.init] User settings did not exist, it has been created for you");
|
consoleLog("[bot.init] User settings does not exist, please hold...");
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
fs.writeFileSync('./config/usersettings.json', "\{\n\}")
|
fs.writeFileSync('./config/usersettings.json', "\{\n\}")
|
||||||
|
} catch(e) {
|
||||||
|
consoleLog(e)
|
||||||
|
consoleLog('[bot.init] [FATAL] User settings file was created but is not writable, could be a permissions issue. Mercury can not start')
|
||||||
|
process.exit()
|
||||||
|
}
|
||||||
|
consoleLog('[bot.init] User settings file has been created')
|
||||||
} else {
|
} else {
|
||||||
consoleLog("[bot.init] User settings file exists");
|
consoleLog("[bot.init] User settings file exists");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await timer(100)
|
await timer(100)
|
||||||
|
if (config.irc.ssl == "true") {
|
||||||
|
consoleLog('[bot.init] Initialisation completed, connecting to '+config.irc.server+'/'+config.irc.port+' (SSL) as '+config.irc.nickname);
|
||||||
|
} else {
|
||||||
consoleLog('[bot.init] Initialisation completed, connecting to '+config.irc.server+'/'+config.irc.port+' as '+config.irc.nickname);
|
consoleLog('[bot.init] Initialisation completed, connecting to '+config.irc.server+'/'+config.irc.port+' as '+config.irc.nickname);
|
||||||
|
}
|
||||||
|
consoleLog('[bot] Welcome to Mercury');
|
||||||
}
|
}
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
Loading…
Reference in New Issue
Block a user