recime-bot-runtime
Version:
This runtime is intended to run inside a micro-service container with platform specific integration and module interpreter.
36 lines (35 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs");
var HandleBars = require("handlebars");
var bot_model_1 = require("./bot-model");
var Dialog = /** @class */ (function () {
function Dialog() {
}
Dialog.html = function (context) {
return new Promise(function (resolve, reject) {
var bot = new bot_model_1.BotModel(context.id);
fs.readFile(context.dir + "/success-dialog.html", 'utf-8', function (err, code) {
if (err) {
return reject(err);
}
return bot.get().then(function (_bot) {
if (_bot) {
var template = HandleBars.compile(code);
context.title = _bot.name;
context.description = _bot.description;
context.id = _bot.id;
resolve(template(context));
}
else {
reject(new Error("Bot not found!"));
}
}).catch(function (err) {
reject(err);
});
});
});
};
return Dialog;
}());
exports.Dialog = Dialog;