Add messageConf support

This commit is contained in:
Bryan Ashby 2018-07-22 15:58:13 -06:00
parent c5998aa343
commit 601433be40
1 changed files with 29 additions and 11 deletions

View File

@ -43,6 +43,8 @@ exports.getModule = class ShowArtModule extends MenuModule {
sequence : self.showBySequence, sequence : self.showBySequence,
random : self.showByRandom, random : self.showByRandom,
fileBaseArea : self.showByFileBaseArea, fileBaseArea : self.showByFileBaseArea,
messageConf : self.showByMessageConf,
messageArea : self.showByMessageArea,
}[self.config.method] || self.showRandomArt; }[self.config.method] || self.showRandomArt;
handler = handler.bind(self); handler = handler.bind(self);
@ -88,18 +90,34 @@ exports.getModule = class ShowArtModule extends MenuModule {
if(err) { if(err) {
return cb(err); return cb(err);
} }
return this.displaySingleArtByConfigPath( [ 'fileBase', 'areas', key, 'art' ], cb);
});
}
// further resolve key -> file base area art showByMessageConf(cb) {
const artSpec = _.get(Config(), [ 'fileBase', 'areas', key, 'art' ]); this.getArtKeyValue( (err, key) => {
if(err) {
return cb(err);
}
return this.displaySingleArtByConfigPath( [ 'messageConferences', key, 'art' ], cb);
});
}
showByMessageArea(cb) {
return cb(null); // NYI
}
displaySingleArtByConfigPath(configPath, cb) {
const desc = configPath.join('.');
const artSpec = _.get(Config(), configPath);
if(!artSpec) { if(!artSpec) {
return cb(Errors.MissingConfig(`No art defined for file base area "${key}"`)); return cb(Errors.MissingConfig(`No art defined at path ${desc}`));
} }
const options = { const options = {
desc,
pause : this.shouldPause(), pause : this.shouldPause(),
desc : 'fileBaseArea',
}; };
return this.displaySingleArtWithOptions(artSpec, options, cb); return this.displaySingleArtWithOptions(artSpec, options, cb);
});
} }
getArtKeyValue(cb) { getArtKeyValue(cb) {