UNPKG

1.27 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var fs = require("fs");
4var HandleBars = require("handlebars");
5var bot_model_1 = require("./bot-model");
6var Dialog = /** @class */ (function () {
7 function Dialog() {
8 }
9 Dialog.html = function (context) {
10 return new Promise(function (resolve, reject) {
11 var bot = new bot_model_1.BotModel(context.id);
12 fs.readFile(context.dir + "/success-dialog.html", 'utf-8', function (err, code) {
13 if (err) {
14 return reject(err);
15 }
16 return bot.get().then(function (_bot) {
17 if (_bot) {
18 var template = HandleBars.compile(code);
19 context.title = _bot.name;
20 context.description = _bot.description;
21 context.id = _bot.id;
22 resolve(template(context));
23 }
24 else {
25 reject(new Error("Bot not found!"));
26 }
27 }).catch(function (err) {
28 reject(err);
29 });
30 });
31 });
32 };
33 return Dialog;
34}());
35exports.Dialog = Dialog;