From 9018bc363cb11ef0f59d658c9f91a4720dcb00be Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Fri, 24 May 2019 22:26:27 -0600 Subject: [PATCH] show_art module can now take Buffer to display --- core/show_art.js | 9 +++++++++ core/theme.js | 21 +++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/core/show_art.js b/core/show_art.js index a480fa05..7e53ca60 100644 --- a/core/show_art.js +++ b/core/show_art.js @@ -68,6 +68,15 @@ exports.getModule = class ShowArtModule extends MenuModule { } showByExtraArgs(cb) { + const artData = _.get(this.config, 'extraArgs.artData'); + if(Buffer.isBuffer(artData)) { + const options = { + pause : this.shouldPause(), + desc : 'extraArgs', + }; + return this.displaySingleArtWithOptions(artData, options, cb); + } + this.getArtKeyValue(this.config.key, (err, artSpec) => { if(err) { return cb(err); diff --git a/core/theme.js b/core/theme.js index 8460cf24..a2d31df1 100644 --- a/core/theme.js +++ b/core/theme.js @@ -27,6 +27,7 @@ exports.getAvailableThemes = getAvailableThemes; exports.getRandomTheme = getRandomTheme; exports.setClientTheme = setClientTheme; exports.initAvailableThemes = initAvailableThemes; +exports.displayPreparedArt = displayPreparedArt; exports.displayThemeArt = displayThemeArt; exports.displayThemedPause = displayThemedPause; exports.displayThemedPrompt = displayThemedPrompt; @@ -510,6 +511,17 @@ function getThemeArt(options, cb) { ); } +function displayPreparedArt(options, artInfo, cb) { + const displayOpts = { + sauce : artInfo.sauce, + font : options.font, + trailingLF : options.trailingLF, + }; + art.display(options.client, artInfo.data, displayOpts, (err, mciMap, extraInfo) => { + return cb(err, { mciMap : mciMap, artInfo : artInfo, extraInfo : extraInfo } ); + }); +} + function displayThemeArt(options, cb) { assert(_.isObject(options)); assert(_.isObject(options.client)); @@ -537,14 +549,7 @@ function displayThemeArt(options, cb) { } }, function disp(artInfo, callback) { - const displayOpts = { - sauce : artInfo.sauce, - font : options.font, - trailingLF : options.trailingLF, - }; - art.display(options.client, artInfo.data, displayOpts, (err, mciMap, extraInfo) => { - return callback(err, { mciMap : mciMap, artInfo : artInfo, extraInfo : extraInfo } ); - }); + return displayPreparedArt(options, artInfo, callback); } ], (err, artData) => {