umbot
Version:
Мультиплатформенный фреймворк для создания голосовых навыков и чат-ботов с единой бизнес-логикой. Встроенная поддержка ВКонтакте, Telegram, Viber, MAX, Яндекс Алисы, Маруси и Сбера SmartApp. Архитектура на адаптерах позволяет подключать любые другие платф
58 lines (57 loc) • 1.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.buttonProcessing = buttonProcessing;
const index_1 = require("../../../index");
const utils_1 = require("../Base/utils");
/**
* Получение кнопок в формате SmartApp
* @param buttons Кнопки, которые необходимо отобразить
* @param isCard флаг принадлежности кнопок к карточке
*/
function buttonProcessing(buttons, isCard = false) {
const objects = [];
if (isCard) {
const button = buttons[0];
if (button) {
if (button.url) {
return {
deep_link: button.url,
type: 'deep_link',
};
}
else {
const text = index_1.Text.resize(button.title || '', 64);
if (text) {
return {
text,
type: 'text',
};
}
}
}
}
else {
(0, utils_1.getCorrectButtons)(buttons, 8).forEach((button) => {
const title = index_1.Text.resize(button.title || '', 64);
if (title) {
const object = {
title,
};
if (button.payload) {
object.action = {
server_action: button.payload,
type: 'server_action',
};
}
else {
object.action = {
text: title,
type: 'text',
};
}
objects.push(object);
}
});
}
return objects;
}