Add somewhat decent error handling finally

This commit is contained in:
hgw 2023-10-02 02:11:26 +00:00
parent 93370c7fe2
commit 1f0b700e82
2 changed files with 16 additions and 4 deletions

13
bot.js
View File

@ -134,11 +134,18 @@ fs.open('./config/usersettings.json','r',function(err, fd){
if(err) { if(err) {
console.log(err); console.log(err);
} }
console.log("usersettings.json did not exist, it has been created"); console.log("[main.setup] usersettings.json did not exist, it has been created");
}); });
fs.writeFileSync('./config/usersettings.json', "\{\n\}") fs.writeFileSync('./config/usersettings.json', "\{\n\}")
} else { } else {
console.log("usersettings.json exists, continuing"); console.log("[main] usersettings.json exists, continuing");
} }
}); });
console.log('[main.irc] Connecting to '+config.irc.server+'/'+config.irc.port+' as '+config.irc.nickname); console.log('[main.irc] Connecting to '+config.irc.server+'/'+config.irc.port+' as '+config.irc.nickname);
process.on('uncaughtException', function (err) {
console.error(err);
if (config.errorhandling.log_errors_to_irc == 'true') {
bot.say(config.errorhandling.error_channel, errorMsg+" "+err.stack.split('\n',1).join(" "))
}
});

View File

@ -8,12 +8,17 @@
], ],
"nickname": "mercury", "nickname": "mercury",
"username": "mercury", "username": "mercury",
"realname": "git.supernets.org/hogwart7/mercury", "realname": "git.supernets.org/hgw/mercury",
"autorejoin": "true", "autorejoin": "true",
"floodprotection": "false", "floodprotection": "false",
"floodprotectiondelay": "0", "floodprotectiondelay": "0",
"prefix": "m!" "prefix": "m!"
}, },
"errorhandling": {
"error_logging": "true",
"error_channel": "#CHANNELTOSENDERRORSTO",
"error_channel_pass": ""
},
"colours": { "colours": {
"date": "11", "date": "11",
"brackets": "15", "brackets": "15",