UNPKG

umbot

Version:

Мультиплатформенный фреймворк для создания голосовых навыков и чат-ботов с единой бизнес-логикой. Встроенная поддержка ВКонтакте, Telegram, Viber, MAX, Яндекс Алисы, Маруси и Сбера SmartApp. Архитектура на адаптерах позволяет подключать любые другие платф

56 lines (55 loc) 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buttonProcessing = buttonProcessing; const index_1 = require("../../../index"); const utils_1 = require("../Base/utils"); /** * Создание кнопки в формате Маруси */ function _getButton(button, isCard) { const title = index_1.Text.resize(button.title || '', 64); if (title) { let object; if (isCard) { object = { text: title, }; } else { object = { title, hide: button.hide, }; } if (button.payload) { object.payload = button.payload; } if (button.url) { object.url = index_1.Text.resize(button.url, 1024); } return object; } return null; } /** * Получение кнопок в формате Маруси * @param buttons Кнопки, которые необходимо отобразить * @param isCard флаг принадлежности кнопок к карточке */ function buttonProcessing(buttons, isCard = false) { const objects = []; if (isCard) { if (buttons.length) { return _getButton(buttons[0], isCard); } } else { (0, utils_1.getCorrectButtons)(buttons).forEach((button) => { const object = _getButton(button, isCard); if (object) { objects.push(object); } }); } return objects; }