1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var fs = require("fs");
|
4 | var HandleBars = require("handlebars");
|
5 | var bot_model_1 = require("./bot-model");
|
6 | var Dialog = (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 | }());
|
35 | exports.Dialog = Dialog;
|