UNPKG

@ebonydevcopy/framework

Version:

A module-based NodeJS chatbot framework.

38 lines 1.26 kB
"use strict"; /** * ebony-framework * * @module handlers/text * @author Christos Panagiotakopoulos <chrispanag@gmail.com> * @copyright Copyright(c) 2020 Christos Panagiotakopoulos * @license MIT * */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const TextMatcher_1 = __importDefault(require("../routers/TextMatcher")); function defaultNlp(user, message, nlp) { if (!nlp) { console.log('No NLP Handler'); } return Promise.resolve(); } function textHandlerFactory(matcher = new TextMatcher_1.default(), nlpHandler = defaultNlp) { function textHandler(message, nlp, user) { const action = matcher.ruleMatcher(message); if (action) { // This is needs a check when we update on this version // Cause now second argument is an object and not just a string return action(user, message); } if (nlp) { console.log('Sending to NLP Handler'); return nlpHandler(user, message, nlp); } } return textHandler; } exports.default = textHandlerFactory; //# sourceMappingURL=text.js.map