UNPKG

bottender

Version:

A framework for building conversational user interfaces.

43 lines 1.44 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const lodash_1 = require("lodash"); const ConsoleBot_1 = __importDefault(require("../console/ConsoleBot")); const __1 = require(".."); const getBottenderConfig_1 = __importDefault(require("./getBottenderConfig")); function getConsoleBot() { const bottenderConfig = getBottenderConfig_1.default(); const { initialState, plugins } = lodash_1.merge(bottenderConfig); const sessionStore = __1.getSessionStore(); const Entry = require(path_1.default.resolve('index.js')); let ErrorEntry; try { ErrorEntry = require(path_1.default.resolve('_error.js')); } catch (err) { } function initializeBot(bot) { if (initialState) { bot.setInitialState(initialState); } if (plugins) { plugins.forEach((plugin) => { bot.use(plugin); }); } bot.onEvent(Entry); if (ErrorEntry) { bot.onError(ErrorEntry); } } const bot = new ConsoleBot_1.default({ fallbackMethods: true, sessionStore, }); initializeBot(bot); return bot; } exports.default = getConsoleBot; //# sourceMappingURL=getConsoleBot.js.map