UNPKG

yandex-dialoger

Version:

Ещё одна библиотека/фреймворк для разработки навыков Алисы.

38 lines (37 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SceneProcessor = void 0; class SceneProcessor { constructor(inputHandler, replyHandler, helpHandler, unrecognizedHandler) { this.inputHandler = inputHandler; this.replyHandler = replyHandler; this.helpHandler = helpHandler; this.unrecognizedHandler = unrecognizedHandler; this.applyReply = (replyBuilder, state) => { if (this.replyHandler) { this.replyHandler(replyBuilder, state); } }; this.applyHelp = (replyBuilder, state) => { var _a, _b; const handler = (_b = (_a = this.helpHandler) !== null && _a !== void 0 ? _a : this.unrecognizedHandler) !== null && _b !== void 0 ? _b : this.replyHandler; if (handler) { handler(replyBuilder, state); } }; this.applyUnrecognized = (replyBuilder, state) => { var _a, _b; const handler = (_b = (_a = this.unrecognizedHandler) !== null && _a !== void 0 ? _a : this.helpHandler) !== null && _b !== void 0 ? _b : this.replyHandler; if (handler) { handler(replyBuilder, state); } }; } hasReply() { return Boolean(this.replyHandler); } async applyInput(inputData, state) { return this.inputHandler(inputData, state); } } exports.SceneProcessor = SceneProcessor;