* Code cleanup. WIP theme stuff. Better CPR handling, etc.

This commit is contained in:
NuSkooler 2014-10-29 22:23:44 -06:00
parent 7cfe72d53b
commit 1ef9a4a1ce
11 changed files with 147 additions and 125 deletions

View file

@ -119,7 +119,9 @@ function startListening() {
client.on('ready', function onClientReady() {
// Go to module -- use default error handler
modules.goto(conf.config.entryMod, client);
prepareClient(client, function onPrepared() {
modules.goto(conf.config.entryMod, client);
});
});
client.on('end', function onClientEnd() {
@ -156,4 +158,22 @@ function removeClient(client) {
clientConnections.splice(i, 1);
logger.log.debug('Connection count is now %d', clientConnections.length);
}
}
function prepareClient(client, cb) {
if('*' === conf.config.preLoginTheme) {
var theme = require('./theme.js');
theme.getRandomTheme(function onRandTheme(err, themeId) {
if(err) {
// :TODO: how to propertly set default/fallback?
client.user.properties.art_theme_name = '';
} else {
client.user.properties.art_theme_name = themeId;
}
cb();
});
} else {
client.user.properties.art_theme_name = conf.config.preLoginTheme;
cb();
}
}